#networks

1 messages · Page 33 of 1

ember ledge
#

and i think encrypting the traffic would be great but i dont know how tho

#

i dont know how the key would encrypt the data and send it to the car

hollow topaz
#

https://en.wikipedia.org/wiki/Remote_keyless_system

Go down, theres a security section :)

A smart entry system is an electronic lock that controls access to a building or vehicle without using a traditional mechanical key. The term keyless entry system originally meant a lock controlled by a keypad located at or near the driver's door, which required entering a predetermined (or self-programmed) numeric code. Such systems now have a...

digital ether
#

Hello! I'm making a server with the socket library, but don't know what localhost port to use. Maybe the port I choose is used by some other application. How do I decide a port for my server?

ember ledge
#

just a heads up, it wont be secure if u do that

#

there WILL be cracks

#

use an open source ready made server

#

unless u want to learn how to make one, go ahead @digital ether

digital ether
ember ledge
#

im not sure but im just giving a heads up if u want to use it for something formal

#

using a ready made and well known DB server is better

ember ledge
#

a proxy

prisma cobalt
#

the system used is the same as how would open a garadge door i believe, the key and car have a chip that changes the value of each request based on an algorithm with a seed only the car and key know, so if i were to record the open request from you key and try to open your car with that data the next day lets say, it wouldnt work because when you unlocked the car, the key and car both did a +1 in their programming and the unlock request data is different now

#

the reason this gets bypassed is this:

  1. if i block your first request to unlock and record the data of the request
  2. you press the key again, assuming your too far away or you didnt click it hard enough
  3. i record the second request and then play the first recorded data back to the car which unlocks it
  4. i now have the data on the next request from the algorithm meaning i could unlock and potentially steal your car anytime
#

that make sense?

#

also i think there more going on behind the scenes so make sure you check it out properly

pure dome
#

Sorry, I didn't understand this

young cypress
#

So once you have a radio receiver device

#

you'll need a device driver and a python interface to that driver

#

Even at this point it's not clear what data you are expecting, and I haven't worked with radio waves before, but i don't assume you're trying to tune in to FM 106.5 and play the station

chrome scroll
#

Would anyone recommend a good error correcting packet framework?

#

Or would this kind of thing not even be needed with python

strange swift
#

I used scapy to sniff my network, and this is all I get as output

#

actually, I guess that could be because it only works on http, not https

prisma cobalt
cosmic cedar
#

anyone can help me with socket library python?

verbal sparrow
#

Hey there everyone! 👋 Hope y'all are doing great 🤗

I just wanted to ask a question,
I have a socket chat application, but Instead of threading and making it complicated, I would rather stick to asyncio. Is there anyway to have a clean Asyncio Approach to making such huge chat applications?

Please guide me 🙏 and Do link to anything external if possible, Appreciate your help a lot! hehe

hazy forge
#

This saves the file the to the folder called logs! However doesn't send the data to the other connection?

#

Anyone know why?

prisma cobalt
prisma cobalt
hazy forge
prisma cobalt
#

and was it?

hazy forge
#

I don't know why it isn't sending the data though?

prisma cobalt
hazy forge
prisma cobalt
#

thats weird

hazy forge
#

Yes.

#

@prisma cobalt You got anymore ideas?

prisma cobalt
#

like does it print file transferred correctly?

prisma cobalt
# hazy forge

also you are sending "done" to the other file but the other file isnt recv anything

#

that might block your program

hazy forge
#

Oh ok.

#

@prisma cobalt?

prisma cobalt
#

your getting a TypeError

ember ledge
#

Uhh I Wanna host my own server and was wondering if this raspberry pi was a good place to start

prisma cobalt
flat umbra
#

Hey what are pririquisites to study networking ?

icy vector
#

@ember ledge

hazy forge
fierce pivot
fierce pivot
#

Socket to understand the princip of connection, and sockets xD and scapy to understand the packets princip

flat umbra
#

Ok bro

#

Well I thought of starting it from scratch

flat umbra
vale epoch
#

Hello, I am kinda confused in what port 514 is used for

#

The syslog port

median lynx
#

Any Scapy professionals?

#

Please DM me

#

If you are a Scapy pro

fierce pivot
#

But i've a question 🤣

#

Someone knows how (in scapy) to translate from scapy Packet, hexstr or py bytes to plain text :
I use the sniff function. If i sniff a GET request, i ame able to get, from packet, hexdump or bytes, the plain GET / HTTP... ?

tough dagger
#

I have no idea how the mentioned library work, but yes if you have plain pocket data you may get plain text from it. Just that it will require to handle extra stuff to glue the message / probably just data. Bytes to string is quite simple, but content may use different encoding than ANSI-US / 7-bit, and it means that anything past CR LF CR LF needs to be decoded based of what's in header. Also header itself might require URL decoding. That's just very simplified case there's more like sessions over same connection. HTTP under SSL/TLS, requests muxing, multi-part, .... Let's say it's not that simple and takes some time to implement properly and if you do want it it's more like exercise.

fierce pivot
#

Thanks ! I'll try to decode using what u said ! 👌

thick pivot
#

Hey everyone!
I'm trying to program a simple server which constantly receives files from a client across separate computers. I was wondering if the following code could work on separate computers:

Server (file receiver):

import socket

while True:
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(HostnameOfTheClientComputerGoesHere, 8080))
        receiving_file = open(FilePathForTheIncomingFileGoesHere, 'wb')
        filedata = s.recv(1024)
        receiving_file.write(filedata)
    except:
        pass

Client (file sender):

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((socket.gethostname(), 8080))
s.listen(1)
while True:
    conn, addr = s.accept()
    break
epicmoners = open(FileToBeSent, 'rb')
monersread = epicmoners.read(1024)
conn.send(monersread)

Sorry for the weird variable names

fierce pivot
# thick pivot Hey everyone! I'm trying to program a simple server which constantly receives fi...

Well, maybe u should modify some things :

Foa, u should make that SERVER will bind, and client will connect. It's good to do that because server ça be online and client not.
But it should work, if u change, on the actual client py s.bind((socket.gethostbyname(), 8080)) by py s.bind(("0.0.0.0", 8080)). It work better because it is bind on every network that is aviable, such as ure lan and/or internet.

After, i wrote the entire code. If u dont want to see it, just dont look ;)

||Client

from socket import socket, AF_INET, SOCK_STREAM
PathToFile = input("Please enter file path : ")
with open(PathToFile, "rb") as r:
    data = r.read()
s = socket(AF_INET, SOCK_STREAM)
try:
    s.connect((ServerIPAddress, 8080))
except:
    print("Could not connect to server !!!")
s.send(data)
s.close()
print("Done !")```

Server
```py
from socket import socket, AF_INET, SOCK_STREAM

s = socket(AF_INET, SOCK_STREAM)
s.bind(("0.0.0.0", 8080))
s.listen(5)
while True:
    conn, (ip, port) = s.accept()
    print(ip, "connect !")
    data = conn.recv(4096)
    pathToFile = input("Please enter place to save file : ")
    with open(pathToFile, "wb+") as r:
        r.write(data)
    conn.close()
s.close()```||
prisma cobalt
#

for one in your client, if it cant connect to the server then it still trys to send data lol, resulting in an error

#

also this makes the assumption that the file is under 4 kilobytes, it wont work if its more (which is very likely)

gloomy root
#

it also assumes that you will actually be able to read the full 4kib if it actually is there

fierce pivot
#

Maybe just dont set a max size ?

wide plover
#

Hi, I am new to networking, is it possible to connect multiple computers using socket?.

prisma cobalt
clear rock
torn arrow
#

How I can make my socket server always alive?

agile anchor
#

What's a good introductory tutorial/text/video to get started with networking in Python?

broken hornet
#

I feel like a legitimate dumb ass

high delta
#

hi guys.
two questions:

  1. how can I locally host jupyter lab and have a friend of mine so we can have a little coding party using my home computer?
  2. are there any python modals folks use for secure crt?
prisma cobalt
#

for as long as its running "its alive"

torn arrow
prisma cobalt
#

for as long as you run it

torn arrow
#

I want always on :(

prisma cobalt
#

then keep the process running 😂

#

your probably looking to outsource to a hosting site

torn arrow
#

Which

prisma cobalt
#

AWS
Heroku
to name a few

torn arrow
#

Heroku free?

prisma cobalt
#

both are but AWS requires you to enter your card details anyway

torn arrow
#

Heroku then

dapper pulsar
#

hi, with the auto-installation feature in https://pypi.org/project/justuse now fairly solid, i'm trying to come up with a way to integrate it with a P2P network in order to relieve PyPI from some of the load.. thinking of the search feature they had to remove because of the burden, so i was wondering if anyone here might have an idea how to realize that in a P2P way? maybe a decentralized database?

#

are there any frameworks that might work? otherwise, I'd use zmq to build it from the ground up, but i have only very limited experience with P2P network design

fierce pivot
prisma cobalt
fierce pivot
#

True xD

waxen cradle
#

Is there some kind of way to get or fish incoming data that gets sent from external servers. For instance if you are browsing on a website, data gets sent from the server to your browser. Can we access that data?

prisma cobalt
humble sigil
#

Hi guys, I'm trying to finish off a file transfer program where I have a server post some basic post-file receipt analysis, but the line where i try to close the socket pycharm reports that "this code is unreachable"? Any idea what would remedy this?

trim moth
#

maybe the socket is getting close only on one of the sides of the transferr (the sender or receiver) and the other one tries to send data to the closed socket and errors out

primal leaf
#

Anyone has any free resources for ethical hacking

#

Please message me if u have it

regal forge
#

There used to be a website where you'd "hack" it to get to the next page

#

IDK what it was called though, it kind of implemented a bunch of different languages from html, css, java, c etc

prisma cobalt
regal forge
#

It's very similar! When I did it it was in the early 2010's so likely it got rebranded/updated to be more user friendly

humble sigil
trim moth
humble sigil
#

I was just mentioning.....

trim moth
#

lol

humble sigil
#

anyhow someone helped me a bit earlier with it

trim moth
#

lmao noice

#

what was going wrong lol

dawn creek
#

anyone good with rtmp and sockets, i want to stream from python to rtmp server audio and video

wide sluice
#

I made a cloud server from an old laptop, but I am only able to access it from my local network, how do I set it up so I can access it everywhere?

civic wyvern
#

hi, I want to send encrypted messages (using ceaser cipher) trough a irc channel. the 'client' side is python and 'server' side is c++. Is there an easy way to convert chars to ints that both python and c++ support? I know that python has ord(), but I am not able to find a similar solution at the c++ side. Thanks in advance

gloomy root
#

ord() just converts the UTF-8 character to it's UTF-8 integer representation

#

in the same way you convert ASCII text to a number

civic wyvern
#

Oh thanks, I think I understand correctly

prisma cobalt
#

the pins dance

cold void
#

if someone made an android phone to collect the one using it, what you look first?

tame dagger
#

Hey guys was wondering how to connect to ipv4 host with ipv6 only proxy in python

vital crest
#

Teredo?

carmine tulip
#

doesn't ipv6 only mean only ipv6?

wide sluice
#

for example: my ip is 123.456.0.789, but in my modem settings I can only add 123.456.1.XXX ip's

sage zinc
#

Y’all I’m having trouble understanding how my Western Digital My Cloud EX2 Ultra private cloud works. I’m using the WD My Cloud OS 5 which allows users to create an account to access the folders they have permissions to. Are my files uploaded to WD cloud servers or is this all happening through my NAS?

#

Forgive my naive question, I know very little about networking, NAS, private clouds, file servers, etc.

radiant vortex
#

Hi

#

I need to connect to a layer 2 cisco switch

#

I'm thinking of using SSH, with paramiko or netmiko

#

I wanted to ask, I can set any IP address (for example on vlan1) and use it for SSH?

#

or do I need to like get permissions/ buy an IP address

keen horizon
#

I'm a little confused about what you mean.

You're inside your own network?

Keep in mind Layer 2 switches deal with switching based on MAC addresses not IP addresses. But I don't know what you all have set up.

radiant vortex
#

nothing so far

#

It's for a uni project

keen horizon
#

kk

radiant vortex
#

so what I want to do

#

is configure a switch using python

keen horizon
#

k

radiant vortex
#

so can I assign an Ip address to Vlan 1, then SSH to it

keen horizon
#

so the layer 2 switch itself has an address and ssh port you can connect to?

radiant vortex
#

that's what i'd set up

keen horizon
#

how would you connect to it to do so?

#

you have console access to it?

radiant vortex
#

i'd use console port

keen horizon
#

gotchja

radiant vortex
#

so I'm buying a new switch for the project

keen horizon
#

ah!

#

I was thinking some remote switch you had no access to so this was confusing

#

and this is all self-contained -- you hook this all up and you're not putting it "on" the internet right?

#

there are non-routable addresses available to you for private use

radiant vortex
#

could I still SSH to it if it isn't connected to a router?

keen horizon
#

if you put the switch and the machine running the python code on the same ip range yes

radiant vortex
#

ok

#

ty

keen horizon
#

yeah so looking around Layer 2 switches can be managed and provide a port and address. Likely unless you run DHCP you'll have to assign it an address like 10.0.0.1 on that vlan port when you're in console. And then your python machine can be 10.0.0.2 and you can then talk to it.

If there is DHCP on this network, your machine and the switch will likely pick up an address automatically. So have fun figuring that out.

But if this is all self-contained (your machine + switch only) for demo purposes, you have full control over using any of the RFC1918 non-routable addresses (you've seen and used them probably .. 10.0.0.0/8 or 192.168.0.0/16 for instance). I think there's one other but those are the ones I use most often.

#

good luck with your project

radiant vortex
#

thank you

wide meadow
#

does anybody have a good roasts source for example a subreddit

prime scaffold
#

Hi, I'm new here. I wanna know how to kill a python thread within a specified time.

#

Tried using ctypes and time modules.. but the code crashes sometimes

storm saffron
#

why do you need ctypes

prime scaffold
#

I used a mutithreading to do the task and another multithread to kill that task thread in a specified time

#

To get that threads ID, I used ctypes.pythonapi

#

I used ctypes

#

To raise an exception if the thread is alive after the specified time

#

Im sorry if I'm not explaining it clearly

#

😓

#

If u have any other alternatives, let me know

storm saffron
#

but why not just use the threading library to kill the thread

ember ledge
#

Can you help me ? what is wrong with my code?

#

I a trying to send email with python through outlook

#

well client as client is the error, maybe try just client ?

ember ledge
#

I tried

#

doesn't work

keen horizon
#

why are you trying to do message = client as client @ember ledge

#

you can just do message = client

#

or just use client

#

there's aliasing "as" for a variable like that .. you can do that during imports like you do on line 1, but afaik not when you have a variable assignment like that

ember ledge
#

thanks

plain junco
#

how to create dos?

livid coyote
errant bayBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

livid coyote
#

DoS = Felony 😉

prisma cobalt
livid coyote
prisma cobalt
#

lmao

livid coyote
#

But yeah idk why they’d ask how to commit a felony but people ask dumb stuff sometimes

restive echo
#

Is it possible to run a scan over multiple ips on a single interface in parallel and be faster than a sequential scan?

livid coyote
late mauve
#

@livid coyote

livid coyote
restive echo
tough gull
#

how do i communicate with a website using sockets

#

something like this is obviously not the correct way

#
>>> import socket
>>> s = socket.socket()
>>> s.connect(('google.com', 443))
>>> s.send('hello'.encode())
5
>>> data = s.recv(2048)
>>> data
b'\x15\x03\x01\x00\x02\x02F'
>>> s.send('hello'.encode())
5
>>> data = s.recv(2048)
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    data = s.recv(2048)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
#

pls ping me when answering

tough gull
#

anyone?

simple cedar
#

Please stop with these fake gifts

ruby arch
#

Why it's keep shows me error even though i installed the package modules

light zealot
prisma cobalt
prisma cobalt
#

not sockets

#

it might be possible with sockets but it will be 10x easier with requests

wooden grotto
#
def receive_packet(sock):
    data = b""
    while True:
        try:
            return decode_packet(data)[0]
        except IncompletePacket as exc:
            while len(data) < exc.minimum:
                data += sock.recv(exc.minimum - len(data))

When called, this is throwing the following error:

Utilities.mcrcon.IncompletePacket: 14

During handling of the above exception, another exception occurred:

    data += sock.recv(exc.minimum - len(data))
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

Can anyone help?

fathom condor
#

Hello!
Could someone explain what is meant by this error 😄
An established connection was aborted by the software in your host machine
Im uisng the socket library.

cold void
#

a Wifi Receveiver can be usable in what context

ember ledge
tough gull
green temple
#

Consider a client-router-server network. Clients request for information from the server via the router. Every server has a backup in case it fails. How will you ensure data consistency after using the backup server when the main server fails?

my answer is that by repeatedly updating the backup server like updating every 5 min for instance so the data consistency will be there , am i right or do you guys have some other answer or way to maintain consistency ?

median agate
livid coyote
#

Idk

median agate
#

Doubt it tho

#

He asked in networking

livid coyote
#

Yeah

prisma cobalt
median lynx
#

Any Scapy pros? (PLS DM ME)

soft silo
#

how to get what client sent in server, socket

pine quiver
#

What libraries do you believe that requests uses?

prisma cobalt
#

i know its based on sockets, you can save on a lot of work if you simply use HTTP requests instead of raw sockets

#

thats why i said usually people just use http requests instead of interacting on a raw socket basis

pine quiver
#

You’d save tons of time just using a library for such. All the way down to a low level, each request is made using a socket. The kid has the right idea, but the wrong way of carrying out such.

prisma cobalt
#

thats what i said 😂

prisma cobalt
pine quiver
#

In a way, but not in a way helpful to the kid.

prisma cobalt
#

i directed them to the requests lib lol
neither of us have strictly answered their question

pine quiver
#

You can easily create such with the socket lib; Whilst being low level and time consuming, it’s generally not the most agreeable way to go about conveying such a task.

#

Yeah

#

good ol requests :)

#

I wonder what one would do if they came into work and were prompted to write an HTTP server in assembly

ember ledge
#

quit?

pine quiver
#

Yeah, that’d probably be what I’d do

#

Just walk right out

junior crag
#

If I were to login to a website using requests, would that session still be active? for example, if I logged into a website, can I then make requests to other parts of the website without needing to log back in?

clear bobcat
junior crag
clear bobcat
#

!d requests.request

errant bayBOT
#

requests.request(method, url, **kwargs)```
Constructs and sends a [`Request`](https://requests.readthedocs.io/en/stable/api/#requests.Request "requests.Request").
clear bobcat
#

Pff

#
requests.get(url, cookies={"session": "id"})
#

!d requests.Session

errant bayBOT
#

class requests.Session```
A Requests session.

Provides cookie persistence, connection-pooling, and configuration.

Basic Usage:

```py
>>> import requests
>>> s = requests.Session()
>>> s.get('https://httpbin.org/get')
<Response [200]>
```...
clear bobcat
cold void
#

!d requests.requests

radiant vortex
#

Hi, other than the serial library, is any alternative for using a console cable to connect to a switch?

#

In python I mean

covert jungle
#

what lib(s) should i look into if i wanna make something like this?:

Computer A can modify a variable (using keyboard input) and sends them (constantly(?)) to <?> from where Computer B can read the values and make actions based on them

would like it to be pretty fast (under 100ms would be really nice)

#

is that even doable lol

narrow oak
covert jungle
#

wdym by "connected"?

narrow oak
covert jungle
#

neither i think .______.

#

both would run a Python script

#

one would be the sender and one would be the receiver

#

but i have no clue how to connect them really

narrow oak
covert jungle
#

was my first thought but wanted to ask here to make sure

#

since I have no experience with that

narrow oak
#

It probably does what you want, it's also a good starting point if u want to learn something else networking related later

covert jungle
#

roger that

#

thank you!

whole mural
#

And wich libs for a simple chat between 2 computer in 2 diffrrent networks ?

#

Sockets too?

narrow oak
#

If you're making a web based, using websocket is want u want

whole mural
#

And if the computers are in the same network?

narrow oak
#

Same thing, shouldn't really affect the technology being used

whole mural
#

Mmh ok

#

Thx

whole mural
narrow oak
#

If you're making a website, then websockets is probably the only solution, but if you're making something else then sockets is probably an alternative.

whole mural
#

Okay

ember ledge
#

!d requests.Request

errant bayBOT
#

class requests.Request(method=None, url=None, headers=None, files=None, data=None, params=None, auth=None, cookies=None, hooks=None, json=None)```
A user-created [`Request`](https://requests.readthedocs.io/en/stable/api/#requests.Request "requests.Request") object.

Used to prepare a [`PreparedRequest`](https://requests.readthedocs.io/en/stable/api/#requests.PreparedRequest "requests.PreparedRequest"), which is sent to the server.
low portal
#

Why am i getting [Errno 11001] getaddrinfo failed?
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.bind((MY_IP_ADDR, 5000))

opaque nymph
#

😭

opaque nymph
#

oh wait

#

thats the code

#

um... idrk

low portal
#

That is the code

opaque nymph
#

idk how to solve it

#

sry

#

😭

#

:jk:

#

jkjkjk

#

1234567889

#

123456789

#

0123456789

#

ill shut up now 🙂

#

...

#

🙂

prisma cobalt
#

its probably wrong

low portal
#

my external ipv6

prisma cobalt
#

hmm

strong timber
#

i have a problem, when i try to connect server and client with public ip adresses i get this error: OSError: [WinError 10049] The requested address is invalid in this context

#
PORT = 5050
SERVER = '178.197.224.96'
ADDR = (SERVER, PORT)

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)
ember ledge
# low portal my external ipv6

you can t bind ipv6 with socket.AF_INET, i belive there is something like socket.AF_INET6 also, you can t bind your external, you need to learn how to do port forwarding

#

@strong timber You actually need to bind your local computer's ipv4 address, then in the router settings you have to redirect the packets that come in the router from the 5050 port to the computer ip also on the 5050 port

strong timber
#

Do you have a tutorial or something ?

prisma cobalt
ruby void
#

pls i need help on how i can connect two computers and also be able to send images between them. i really dont know where to start

low portal
#

There r some pinned comments in this channel that has some resources

prisma cobalt
empty iron
#

I am new to python and am trying to use zeep to make soap requests to wsdl service against wsbinding with user name and password.
However, i keep on getting 400 bad requests error. Anyone can help me troubleshoot?

tranquil ember
empty iron
young cypress
empty iron
#

After an entire day debugging, I think this soap service doesn't work with Python. Bumner

ember ledge
#

hello people

#

ig load balancing is the concept of networking right?

#

i have a question, i wanna learn the whole concept

#

i have solved the first, second part, but m stuck at the third

latent socket
#

How to recv large data faster in socket ?

#

I need help with it

latent socket
#

Thats not a solution
I may transfer 500 mb

#

Tell a permanent solution

#

For all kind of things

remote delta
cold void
# errant bay

you can request specific files like .png with files='pn'?

flat rain
#

python need help

#

with csrf token

#

ping me here if youre here sir

flat rain
#
csrf = client.get(url).cookies['csrftoken']

I tried this but it dint work so idk how tograb the csrf token

#

the response

ember ledge
#

why are you trying to do this exactly

teal elm
#

He's trying to grab the csrf that is set by the post requests probably because he needs for a header

#

@flat rain go to main page load it look into the html search csrf should be in there then it's probably a header that's added to the post request

#

Use fiddler or something to see the requests or even debug menu in chrome

#

@flat rain feel free to dm me for more help

proud osprey
#

hello. Any guide about how to reply an email in the same thread? So far I've found only this https://stackoverflow.com/q/31433633/

worldly lotus
#

I wanna store one file in a cloud or something so I can do this:

with open(get_file_from_cloud, "wb") as f:
    f.write(b"IDK")

send_changes_to_cloud_and_update_file()

Is there a way to do something like this?

clear bobcat
#

Which cloud are you using?

worldly lotus
#

I dont have any

#

im doing this for the summer jam this year, so I am NOT willing to pay

clear bobcat
worldly lotus
clear bobcat
worldly lotus
#

is there any api wrapper for it?

clear bobcat
worldly lotus
#

k ty

clear bobcat
#

👍

tulip granite
tulip granite
#

Please I am entirely desperate

stray jungle
#

Anyone around here?

#

Consider me a complete noob because I totally don't how to do what I am about to say or even if I'm in the right place for it, can we upload images to some sort of a temporary server or website atleast 1 image per second with enough speed that discord can render it like a really low fps game in an embed ||yes this is a discord bot project idea||

steady horizon
stray jungle
#

Well we could change the source and leave the end link the same 🙃

steady horizon
#

That... idk... honestly

stray jungle
#

Is there a database of sorts that can handle images really well?

steady horizon
#

You will probably need to refresh the channel or click the image again or something though idk

steady horizon
#

and it's not the right channel to ask that question in

stray jungle
#

🙁

#

I've had this idea for multiple months now and my knowledge of python is very low and am just being desperate at this point

#

Because if this is possible it'll be a brand new way in chat games

steady horizon
stray jungle
#

I might have been talking bs, cuz I clearly have no clue what I'm talking about

steady horizon
#

@stray jungle user-experience-wise, I think it's a horrible idea, as I don't think snake on Discord like that would be fun to people who can't type fast for responses, and buttons aren't fully out on discord.py

stray jungle
#

The closest solution I found was to use imgur, but I can't even figure out how to upload an image

#

😭

steady horizon
stray jungle
#

I did just that I'm a total noob at this

stray jungle
#

Thanks for ur time tho

steady horizon
stray jungle
#

Just if you see a chat game blowing up some day just remember where u heard it first || jk I'm just fantasizing at this point 😂 ||

steady horizon
#

good luck bro honestly

stray jungle
#

I have almost 50% of the plot for the game planned out

#

If this doesn't happen ig I'll just make a boring old text chat game, like all others

steady horizon
#

Or, you can make a game with PyGame or something, and publish it on Discord's game store.

stray jungle
#

I did think of that actually

#

But I want it to be more like a multiplayer experience

#

Like it's basically going to be Minecraft X clash of clans but on discord

tulip granite
#

Please I am in desperate need of help

tropic laurel
#

Any clues, why my Linux server is sending ARP requests for an IP outside of its subnet? Here is routing table and a tcpdump when trying to ping IP from different subnet: https://susepaste.org/view/raw/10043871
Can i disable this so that the packets to different subnets will go to the gateway always?

rose oxide
#

Can I know different ways for 2 python scripts to send and receive messages running on different servers? So far I only know sockets. Are there any other and better ways?

#

please ping me in answer

raven flame
#

This probably falls out of the scope of python but someone here will probably know anyway, I have ffmpeg running on a rpi, outputting a tcp h264 stream, are there any tools that could potentially show this in a browser?

proud osprey
#

usually, if you don't do anything on your OS, it will probably rely on what DHCP tells it to do, in your case your router. If you set up something manually then that's what it will use to resolve. You can try dig command to make how names are getting resolved

#

?

tacit loom
#

Haha, yes, just got the answer from a diff server

proud osprey
#

I thought there was a DNS question here

#

😂

tacit loom
#

Device takes precendence

#

But I have a feeling my hostnames are not getting resolved properly

#

I can't use dig Im runnign android

proud osprey
#

oh you mentioned linux

tacit loom
#

I can test it on Linux, but the issue is on Android

proud osprey
#

though there must be networking tools/apps for Android

tacit loom
#

The issue is Im running any app that caputres packets for each app

#

And sees where they are connecting

#

It becomes ewkfejl2123-fastly.com or some other CDN

#

@proud osprey Any ideas lol?

proud osprey
#

seems like you installed something weird in your phone. I'd reset it to fabric

#

and do not use Google "auto restore" option when setting it up again

#

I'd install all what I need manually and restore/setup each app individually

#

good luck

raven zinc
#

hey guys im trying to make a code that tells me when i receive an email i got this online ```import poplib
from email import parser

pop_conn = poplib.POP3_SSL('pop.gmail.com')
pop_conn.user('')
pop_conn.pass_('')
#Get messages from server:
messages = [pop_conn.retr(i) for i in range(1, len(pop_conn.list()[1]) + 1)]

Concat message pieces:

messages = ["\n".join(mssg[1]) for mssg in messages]
#Parse message intom an email object:
messages = [parser.Parser().parsestr(mssg) for mssg in messages]
for message in messages:
print(message['subject'])
pop_conn.quit()```

#

its not working for some reason

#

obviously i put my email and password in

#

heres my error

#

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/poplib.py", line 218, in pass_
return self._shortcmd('PASS %s' % pswd)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/poplib.py", line 181, in _shortcmd
return self._getresp()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/poplib.py", line 157, in _getresp
raise error_proto(resp)
poplib.error_proto: b'-ERR [AUTH] Username and password not accepted.'

proud osprey
#

"some reason" is in the latest line

crystal lake
#

I assume issues relating to funky behavior from Requests would go here?

#

I'm working on a Discord bot, and I need to upload a file to temp.sh, and use the response given from temp.sh/upload
Currently, this is what I've got ```Python
import requests as rq

url = "https://temp.sh/"
filename = "test.zip"

with open(filename, 'rb') as file:
res = rq.post(url, data=file)
print(res.text)``` but every single time I print the response, it's just the raw html from the main site rather than the response that should be given after being redirected

static inlet
#

try changing the post to a put

crystal lake
#

put doesn't work with root either

#

but works just fine on /upload

#

My next headache

#

is figuring out the naming

#

because all my uploads are being saved on the server as just upload

#

no extensions, no other filename

#

just upload

#

But that's a headache for the morning

#

Goodnight nerds, love yall

ember ledge
#

hello ?

#

someone up ?

ember ledge
#

how can i fix that ?

#

code normally fully correct so idk why it doesnt work

#

so does someone of you know how to fix

ember ledge
# ember ledge

Arent the brackets meant to be next to the variables IP AND TCP in order to make then functions?

#

no i think its all right like how i did it

#

but idk why it isnt working

#

only these 3

#

Maybe try removing the space between the brackets and the names

#

nope doesnt work

ember ledge
#

fixed it

#

@ember ledge

#

how

ember ledge
#

forget it to defeny

#

but

#

got now other problem

ember ledge
clear bobcat
ember ledge
#

thx

tropic laurel
#

Hi! What would cause these kind of ping spikes? https://i.imgur.com/sHsLRLL.png We seem to be the only site on the WAN that's affected by it and im pulling my hair out trying to diagnose it

prisma cobalt
rich trench
#

can i post home networing questions in here?

tough gull
#

is there any way i could use the socket module to connect to another private ip / wifi router or network

clear bobcat
tough gull
#

as obviously none of them are public

clear bobcat
tough gull
#

oh

tough gull
clear bobcat
tough gull
#

where did you learn it from?

clear bobcat
#

During lectures

tough gull
#

oh

#

ig i'll try to find some online documentation

regal pendant
#

Hi guys. Can someone help me with getting into Network Automation. I know Python beginner level. Which python module should I learn to do network automation.

#

How can I proceed from beginners python level to network automation level and actually be able to automate network task.

rose oxide
#

I wanna host a flask socket io script on a server. Can it be used with any socket library in frontend like say flutter app with websocket library or do I have to use some specific socketio library for compatibility?

#

please ping me in answer if you answer

rose oxide
regal pendant
winged sentinel
#

@regal pendant have also found request module useful if your network device has an api. You can also check pysnmp

thick fog
#

hi, im new programming in python. Can someone tell me why in line 22 "random" it isnt correct?

thick fog
#

oh ok

#

thanks

narrow oak
regal pendant
ember ledge
ember ledge
#

Beginner here

prisma cobalt
#

could you also show what you have so far

whole mural
#

yo, im learning the socket module but i don't really understand something. "A pair (host, port) is used for the AF_INET address family, where host is a string representing either a hostname in Internet domain notation like 'daring.cwi.nl' or an IPv4 address like '100.50.200.5', and port is an integer."(from python doc). but when i use the gethostname method for the host arg it returns my computer name but it doesn't looks like an internet domain notation. So why my computer name works like an internet domain name?

prisma cobalt
#

your right in saying it cant be used for external network communication (over the internet)

whole mural
prisma cobalt
#

no

rancid bough
#

in general is SMTP really secure? I have seen tones of companies saying their services are this and that but are SMTP services really secure

modest ether
#

Hi, I am trying to learn how to log into websites by sending a post request, can someone please explain to me how to do this. So far I have managed to write a program that fills and sends a google form.

prisma cobalt
#

hmm isnt that against google ToS thinkmonthinkmonthinkmonthinkmon

modest ether
#

I hope not

latent socket
#

Guys asyncio ia best for handling multiple connection and data or default socket

modest ether
#

Is there anything I should include in the post request besides url, user-agent and request payload data?

rough nest
#

Not all of them are important but good to know in case

rose oxide
#

btw thank u for that I didn't read it message until now but I did what u said lol

radiant owl
torn arrow
trail vale
#

😦

wise quail
#

name_button = tkinter.Button(root, text="click here!")
name_button.grid(row=0, column=0)

I get

_tkinter.TclError: cannot use geometry manager grid inside . which already has slaves managed by pack

But the below works fine.

name_button = tkinter.Button(root, text="click here!")
name_button.pack()

ember ledge
#

how can i host my bot 24/7 wihout leaving pc 24/7 rasp pi or paying

flat rain
#

need help

quick rapids
#

Need help guys! I'd like to write a python script to kick unauthorized users off my WiFi network. How should I implement this?

rose oxide
ember ledge
#

Cant zoom more otherwise it wil be out of sight

rose oxide
# ember ledge

I think you can iterate over the range of IP addresses and port numbers provided and then see if u can establish a connection. if connected, write the name of service in the file based on the port number or else skip it

prisma cobalt
prisma cobalt
prisma cobalt
prisma cobalt
# ember ledge

This is a port scanner, there are countless examples on google if you need a reference

hasty perch
#

@ember ledge you can send a timed request packets to each port on those ip address, if they are open, you get a response, otherwise they are closed. Then map those open port numbers with the standard services running on those port. hope it helps

clear anchor
#

Looking for a pretty dumbed down resource for programmng sockets TCP/IP sockets in py. Any resources for my little ol brain?

ember ledge
covert dome
#

Hi. I'm using Flask to create the backend for a non-browser game (with Unity) and have a few questions. Is there a way for the server to push new data to the client without the client needing to query the api at intervals to check if there's new data? I understand there's sockets but how reliable are these? And if flask is not my best option, any recommendations for a non-browser game?

clear bobcat
covert dome
#

@clear bobcat so basically the option is sockets not the standard way of doing flask apps with routes ?

clear bobcat
covert dome
#

got it

#

thanks so much

clear bobcat
#

👍

rose oxide
covert dome
#

@rose oxide any notable advantages/differences between quart and flask?

rose oxide
#

only difference I know of is quart is better as it's async (asgi) and also supports protocols like websockets and http 2

#

@covert dome I'm trying to implement something with websockets too I just got to know about this framework and it works for me. and also you can route the requests as you could using flask.

covert dome
#

sweet... thank you i'll have a look at it. it's my first time using websockets and i jumped right into the deep end with having a network game lol

rose oxide
#

lol same thing for me. I've never used even http stuff this is my first time implementing something like this. good luck and lemme know how it goes

covert dome
#

cheers mate good luck to you too 🙂

ember ledge
#

import socket

HEADER = 64
PORT = 5050
FORMAT = 'utf-8'
DISCONNECT_MESSAGE = "!DISCONNECT"
SERVER = "10.0.0.158"
ADDR = (SERVER, PORT)

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(ADDR)

def send(msg):
message = msg.encode(FORMAT)
msg_length = len(message)
send_length = str(msg_length).encode(FORMAT)
send_length += b' ' * (HEADER - len(send_length))
client.send(send_length)
client.send(message)
print(client.recv(2048).decode(FORMAT))

send("hello")
input()
send("my name is ")
input()
send("bye")

send(DISCONNECT_MESSAGE)

#

import socket
import threading

HEADER = 64
PORT = 5050
SERVER = socket.gethostbyname(socket.gethostname())
ADDR = (SERVER, PORT)
FORMAT = 'utf-8'
DISCONNECT_MESSAGE = "!DISCONNECT"

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)

def handle_client(conn, addr):
print(f"[NEW CONNECTION] {addr} connected.")

connected = True
while connected:
    msg_length = conn.recv(HEADER).decode(FORMAT)
    if msg_length:
        msg_length = int(msg_length)
        msg = conn.recv(msg_length).decode(FORMAT)
        if msg == DISCONNECT_MESSAGE:
            connected = False

        print(f"[{addr}] {msg}")
        conn.send("Msg received".encode(FORMAT))

conn.close()

def start():
server.listen()
print(f"[LISTENING] Server is listening on {SERVER}")
while True:
conn, addr = server.accept()
thread = threading.Thread(target=handle_client, args=(conn, addr))
thread.start()
print(f"[ACTIVE CONNECTIONS] {threading.activeCount() - 1}")

print("[STARTING] server is starting...")
start()

worldly lotus
#

is this a good place to ask questions about http?

rose oxide
#

it certainly is

worldly lotus
#

ok so

#

I want to host a little something I made (aiohttp server) on heroku (which I know is a bad place to use for hosting), but I keep getting 503: Service Unavalivle errors.

#

in the procfile I use ```
worker: python server.py

ruby void
digital bison
#

I have question not related to python

#

I have explained my home network in the above diagram

#

I am able to ping from mobile to desktop.. But was not able to the reverse that is i can ping from desktop to mobile

#

Is there any way to do this?

rose oxide
#

5000 will be default port if it doesnt find PORT variable

worldly lotus
#

also

#

what do I set as host?

rose oxide
#

ummm how r u deploying it?

worldly lotus
#

git

#

git add

#

commit

#

push

rose oxide
#

like gunicorn or something?

worldly lotus
#

no

#

python main,py

#

gunicorn is wsgi

#

"asgi"

rose oxide
#

I see

#

I haven't deployed with wsgi

#

I'm lagging wtf

rose oxide
worldly lotus
rose oxide
#

it worked well for me
I used quart framework btw which is similar to flask but asynchronous

rose oxide
#

if I stop lagging ffs

worldly lotus
#

kk ty

worldly lotus
#

There is one thing that is stopping me now

rose oxide
worldly lotus
#

deploying the thing...

#

It runs with uvicorn on my local

#

but when I build it

#

I get no unbinded port error anymore

rose oxide
#

what address do you provide for host?

worldly lotus
#

no wait I use default

#

but I think default is 0.0.0.0

worldly lotus
#

yes

rose oxide
#

I doubt default is 0000

#

try to configure it to 0.0.0.0

worldly lotus
#

127.0.0.1?

rose oxide
#

that's local host most of the times it's the default

#

so better configure it to be 0.0.0.0

worldly lotus
#

k

#

btw

#

but rather

#

web: uvicorn main:app

rose oxide
#

yea it's fine just make sure you bind it properly

worldly lotus
#

will this do?

#

web: uvicorn main:app --port "0.0.0.0"

rose oxide
#

like for me I was not able to connect properly so I ran hypercorn programmatically to get port from os environments and ran that file

rose oxide
#

otherwise u can use hypercorn and make a python file then run it using python

worldly lotus
#

waaiait

#

holy shit

rose oxide
#

sorry my internet sucks ass today

worldly lotus
#

I think it works

rose oxide
worldly lotus
#

ima test it

#

first

#

ima finish helping this guy in a help channel

rose oxide
#

ight

worldly lotus
#

I think its because heroku thinks that a HttpResponse is supposed to be returned

#

but it aint

rose oxide
#

any errors on log?

rose oxide
worldly lotus
#

found the problem

worldly lotus
#

because of there was no running dyno at all

rose oxide
worldly lotus
#

Sorry my bad

rose oxide
#

lol make a new account I guess

worldly lotus
#

although

rose oxide
#

or buy dynos

worldly lotus
#

I have dynos

#

I just hadnt started them properly

rose oxide
#

try it then

worldly lotus
#

I am now 😄

#

works kinda

#

but it wont close connections properly

stark jolt
#

Hey guys, I need help making a multi-client heartbeat system

worldly lotus
#

but messages that I send keep getting 400 Bad Request

#

soo

#

I think I might know what the problem is

#

the server assigns a port using the $PORT env-variable

#

how would the client know what port to connect to?

rose oxide
rose oxide
worldly lotus
rose oxide
#

if it's websocket try using ws://

worldly lotus
rose oxide
#

it'll work

#

good luck

worldly lotus
#

will that work with

#

python-socketio

#

and FastAPI

#

and asgi servers?

rose oxide
#

it should work

#

but idk about python socketio. you need to implement that asgi callable to run it using asgi server so better use framework

#

I'm not sure if python socketio is already asgi

worldly lotus
#

it is

rose oxide
#

then it should work

worldly zinc
#

Hi, did any of you ever tried algo trading?

wise quail
#

did only auto!

long raptor
#

Can anybody point me to the right direction on how to send data between two python programs containerized in docker? Just simple text locally. I can't find a easy way and I imagine there must be one or a few.

Also please let me know if I'm in the wrong channel, I'm kinda new here and this channel seemed fitting.

ember ledge
#

question, can you get stock market data from heroku

vagrant wasp
#

is anyone familiar with port forwarding for a python socket? i have a socket that works for local connections but i cant make it work for a remote connection even if i forward the port

fierce pivot
#

And sysctl -w net.inet.ip.forwarding=1 on macos

#

Use the same command with 0 to disable

vagrant wasp
fierce pivot
#

Wait a minut

#

Well, look at http://woshub.com/port-forwarding-in-windows/ to see how it works.
I just say u, if u start to do dev, use a linux cputr 🤣 its reeeeeaaaaaaly better than a windows one xD
Or if u dont want to change the os, use a bootable usb x)

Windows OS Hub

You can configure network ports forwarding in all Windows versions without using third-party tools. Using a port forwarding rule, you can redirect an incoming TCP connection (IPv4 or IPv6) from…

#

@vagrant wasp

vagrant wasp
#

haha okay I'll look into using linux for future projects, thanks for your help 🙂

fierce pivot
#

Ure welcome !

sullen hill
#

I couldn't find schema for pymongo?
Isn't there one?

rose oxide
#

this is code for broadcasting using websockets (for quart framework). can someone explain me how this works? what I'm confused about is, we're just adding an asyncio.Queue in the connected_websockets set. idk how it is related to the client websockets. it works but idk how it works

prisma cobalt
fierce pivot
prisma cobalt
#

In which case you need to change the port forwarding rules on the router

fierce pivot
forest storm
#

I am getting this error.

#
from quart_discord import DiscordOAuth2Session
from discord.ext import ipc

app = Quart(__name__)
ipc_client = ipc.Client(secret_key = "", port=3050)

app.config["SECRET_KEY"] = ""
app.config["DISCORD_CLIENT_ID"] = ''   # Discord client ID.
app.config["DISCORD_CLIENT_SECRET"] = ""   # Discord client secret.
app.config["DISCORD_REDIRECT_URI"] = ""  

discord = DiscordOAuth2Session(app)
#---------------------Dashboard--------------------------------

@app.route("/")
async def home():
    return await render_template("index.html", authorized = await discord.authorized)

@app.route("/login")
async def login():
    return await discord.create_session()

@app.route("/callback")
async def callback():
    try:
        await discord.callback()
    except Exception:
        pass

    return redirect(url_for("dashboard"))

@app.route("/dashboard")
async def dashboard():
    if not await discord.authorized:
        return redirect(url_for("login")) 

    guild_count = await ipc_client.request("get_guild_count")
    guild_ids = await ipc_client.request("get_guild_ids")

    user_guilds = await discord.fetch_guilds()

    guilds = []

    for guild in user_guilds:
        if guild.permissions.administrator:            
            guild.class_color = "green-border" if guild.id in guild_ids else "red-border"
            guilds.append(guild)

    guilds.sort(key = lambda x: x.class_color == "red-border")
    name = (await discord.fetch_user()).name
    return await render_template("dashboard.html", guild_count = guild_count, guilds = guilds, username=name)

@app.route("/dashboard/<int:guild_id>")
async def dashboard_server(guild_id):
    if not await discord.authorized:
        return redirect(url_for("login")) 

    guild = await ipc_client.request("get_guild", guild_id = guild_id)
    if guild is None:
        return redirect(f'')
    return guild["name"]


if __name__ == "__main__":
    app.run("0.0.0.0", debug=True, port=3050)```
still steppe
#

hello ,
can we made something.py for blocking website on the network?

and list connected devices on the routers? ( same network)

vagrant wasp
prisma cobalt
vagrant wasp
# prisma cobalt Ooo unlucky, what ISP do you use? It's weird tho, most big ISPs offer port forwa...

I have Spectrum, I have it as a feature technically, but according to the person I spoke with, Spectrum doesn’t like residential port forwarding due to security issues and other reasons. Apparently the newer Spectrum routers don’t have it as a feature at all so I’m “lucky” to have an older router so I have the ability to ~try~ to port forward even though it didn’t seem to work out great for me. Id be able to buy a third party router to do it but I didn’t feel like going through the trouble

#

I also found a cloud server with the cheapest server option being $0.0075 per hour and considering I just need the server to send small bytes of strings or dictionaries it does the trick just fine

#

And I got it from Tech with Tim who had a code that gave $100 in credit, since i’m not running the server 24/7, that $100 is gonna stretch far

prisma cobalt
#

Ofc you could have used another site like aws which would allow you to run it 24/7 for a year for free

vagrant wasp
# prisma cobalt That sounds really good, can I get a link 😄

This tutorial will walk you through hosting a python socket server online where it can be accessed and connected to from anywhere. We will setup a headless linux server and transfer our server side code there. After running the code from our server we will connect our clients.

Get a free $20 credit on Linode using the code TWT19: https://www.li...

▶ Play video
#

This is the video I got it from so you can get the affiliate link, in the video he says you get $20 but you actually get $100. The video also has an easy to follow tutorial on using it 🙂

ember ledge
#

hey

#

so im tryna make requests via http,socks4/5 proxy

#

using socketserver

#

does anyone here know how to do it

ember ledge
#

Any one knows what to send to a STUN server to get back IP?

#

data

gloomy root
ember ledge
#

Like this http request how can we request STUN server

import socket

server = socket.socket(socket.AF_INET ,socket.SOCK_STREAM)
ap = socket.gethostbyname("google.com")
print(ap)
server.connect((ap,80))
dat = "GET / HTTP/1.0\r\n"
dat += "\r\n"
server.send(dat.encode())

data = True
while data:
    data = server.recv(1024)
    if(len(data.decode())==0):
        data = False
    else:
        print(data.decode())
        data = True
gloomy root
#

not sure why you need that in the first place tbh

ember ledge
#

based on NAT transversal

#

Also I am trying to counter symmetric NAT

gloomy root
#

then reading is your friend 🙂

ember ledge
#

reading scripts day and night

gloomy root
#

I mean the article i sent does a pretty reasonable job

#

links you to the other set of articles explaining the mesasge structure, sending messages etc...

#

the actual language implementation is up to you

ember ledge
gloomy root
#

its describing the protocol

#

the protocol doesnt change across implementation

ember ledge
#

after all It's just echoing out IP/PORT

gloomy root
#

that would defeat the entire point of a protocol

ember ledge
#

I am just angry why peer to peer doesn't have a uniform implementation over networks

#

p2p decreases every aspect of load to server

gloomy root
#

because p2p is complicated and differs depending on what you're doing with it

#

WebRTC for example has to use several different setups to provide the support across networks e.g. it needs both UDP and TCP fallbacks, TURN servers for when a network blocks Client to client UDP etc...

fierce pivot
#

Hey !
I need some help on a problem (as usual)
I dont realy know if i'me on the great channel.
I want, with a python code (python 3.8) to send a mail.
I searched, i searched, i searched....
I found some difrent things, but lot of them didnt work.
For example, lot of website was talking about smtplib and emails.utils.
Well, that great but... for a gmail account... that didn't work.
After, i found google_api i actualy didn't try, but works only for gmail accounts. That seems great, but i wanted to know if a (great) lib exist, that allow emails from any smtp clients.

toxic mural
fierce pivot
#

Well, it seems good x)

toxic mural
#

i used that myself before and also wrote some documentation for it but it seems that hasn't been updated since 4 years lol

#

then i'd guess the readme is the best source of information

fierce pivot
#

Thanks !

steady horizon
#

Should I use select or threading?

steady horizon
#

Most tutorials on YouTube use a threading mechanism of some sort, but I also discovered that select can be used for asynchronous socket programming.

#

I already know how to use threading for socket programming but I want to know if select has any benefits or if it can help with anything.

lofty bough
#

@steady horizon Instead of using raw select you can use higher-level asynchronous I/O.

#

asyncio has some primitives for working with sockets

steady horizon
#

Hm. Thanks. I will look into asyncio socket programming.

trim moth
# steady horizon Most tutorials on YouTube use a threading mechanism of some sort, but I also dis...

ig select is primarily for knowing about the state of a particular socket (wether is it ready to read, ready to write, or errored) and you can do some decision making based on the state of a socket as explained in https://www.oreilly.com/library/view/python-standard-library/0596000960/ch07s03.html
while threading seems much different tho, since it's like doing multiple different things at the same time, and finally, with async you can use coroutines and set up event loops to create a sort of pseudo-concurrency while a program runs within a single thread

gloomy root
#

personally, if im doing any sort of low level socket handling I got with asyncio

#

it makes life considerably easier than worrying about selectors etc...

ember ledge
#

hi

#

can you use a wifi analyzer to see the mac address of a wifi access point.. without connecting to it

wide burrow
#

@ me if you can and want to help

pale crest
#

so my friend in korea has a raspberry pi and say I bought one, is there any way we could connect it? like a mini server so because i’m in singapore, if someone from malaysia connected, it would connect to the closer one, which is mine. Or am i getting this whole idea wrong??

someone said something about cdns

wide burrow
#

the way ( the cheapest that I know of and did) is I host an onion site on my rpi and use it as an access pt where I can remote in

#

onion domain is free

prisma cobalt
#

noip is pretty good too

trim moth
wide burrow
prisma cobalt
#

wait wtf where they go

trim moth
wide burrow
prisma cobalt
#

yeah so you need to open ports for that

trim moth
#

well, could have a aws free tier ec2 instace and opening ports on it to use it as a middle man to communicate data between two devices lmao

#

or probably ssh into it :3

prisma cobalt
trim moth
#

dam this idea is getting old lol

trim moth
prisma cobalt
#

lmao

wide burrow
trim moth
#

yee indeed, but I'm talking about opening ports on the EC2 instance

wide burrow
#

Then i have no idea

trim moth
#

lmao

livid coyote
#

I need help with urllib3 and headers

#

I need to make headers included in a get request but Idk how, and I've never used urllib until today

#

someone help! 🙂

still oyster
#

does websocket and socket related questions belongs to here?

light zealot
#

ye

still steppe
#

hello..i need help.
my task is to block websites on network

#

on the same network!!
( not using hosts file)

rose oxide
mellow dock
still steppe
ember ledge
#

Is there a connection limit when using TCP with socket module in python?

#

how much clients/node can be connected with 1 code/1 computer using socket module

#

pls ping

storm saffron
#

@ember ledge 65534 per interface

#

But there might well be per process restrictions

prisma cobalt
prisma cobalt
storm saffron
#

Not with elevation

#

And standard outbound ports won't necessarily be occupied

ember ledge
#

im not trying to check what ports are useable

#

im trying to check on how much nodes can connect to my computer using socket.listen() @storm saffron

storm saffron
#

Yes I know

#

About 65534

#

A bit less

livid coyote
ember ledge
#

@prisma cobalt hello mr networker

trim moth
#

lmao @prisma cobalt got some fanboyism goin on lol, count me in 🤣

prisma cobalt
#

Lmao

solemn mist
#

I am multiple GET requests around 1K using requests library... I guess its a overhead as each request has to setup TCP connection and then make actual request.

Is there any better way to do it ?

fierce pivot
solemn mist
#

@fierce pivot I guess requests lib is using the socket under the hood.

fierce pivot
solemn mist
#

yeah, correct. But my question more towards usage of requests lib 🙂

gloomy root
#

generally, yes establishing connections can be expensive if they're all in a short period of time, but equally not usually enough to be a big issue

#

most of this just comes down to the timeframe of these requests

solemn mist
gloomy root
#

its less the TCP overhead

#

you cant stop the TCP overhead (not that it matters)

#

its the TLS handshakes that tend to take more time, mostly because roundtrips and processing time

#

this is sorta where HTTP/2 comes in

#

basically one connection, many requests

solemn mist
tame badger
#

hey folks, I'm taking over an devops networking/ops team soon but my background is in security

#

does anyone have any recommendations for a good intro to core networking concepts for me to refresh myself

#

wait right there's a pinned intro, always read the pins...

clear bobcat
cedar forum
#

don't have to go into the crazies like Enhanced Interior Gateway Routing Protocol but that site has a fairly good overview of a range of protos, routing, IPv6, NAT, etc.

tame badger
#

thanks guys!

past spindle
#

Anyone have a good document describing application headers to use with TCP communication? It is my first time designing an application layer for that.

steady horizon
#

You write your own headers.

#

You are supposed to plan how messages look and build a protocol from that.

past spindle
#

Right, I just would like a look at some common fields before I get a header design down on paper. I am looking at the DNS header right now, and wondering if there are other good examples. I understand that this is a broad question, and specific application headers are designed for specific use cases. I suppose I am just looking for inspiration/guidance.

cedar forum
#

well, a good starting rule is you don't want to have redundant information in there

#

you're optimising for size, primarily

past spindle
#

Understood. Thanks for that. I will go ahead and sketch something out

ember ledge
#

Hi. I am trying to find someone that can a socket msg program. I am trying to send a socket message from North America to Europe. DM me if you can help. (sorry if I was spamming this message, no one could help me)

#

Nvm I found someone that can help.

pliant kiln
#

hello, how do i capture response cookies? session.cookies() gives me request cookies

#

the one marked in red

#

session.post(url,data) gives me request cookies 😦

acoustic raven
#

How to convert subnet mask to vlan mask... Someone explain it PLz..

steep juniper
#

vlans and subnets are two completely different things

#

so you'd have to elaborate what you want to do

placid tree
dense rivet
#

Does someone know why this casues an OSError about ports being reused?

import socket
from tornado import netutil


def try_socket():
    with socket.socket() as s:
        try:
            s.connect(("localhost", 8888))
        except OSError:
            print("port in use")
        finally:
            s.close()


try_socket()
netutil.bind_sockets(8888, "localhost")
#

Well dang if Im not stupid

#

I have a jupyter notebook server running on that port

narrow oak
#

well, if theres an error stating that the port is being used - thats most likely the case..

prisma cobalt
#

👀 big brain

steady horizon
#

data then begins on two newline characters, and ends with two newline characters

waxen cradle
#

Hi, Im trying to make screen sharing program. Im using
PIL.ImageGrab.grab
to take my screenshot. Then send it over using sockets and display it using opencv. But opencv works with numpy arrays. So I need to convert my screenshot into a np array. But Im having issues with encoding the array and then decoding it properly?

tiny panther
#

You can just send the image as a bytearray or byte string, as well with the shape of it, so you can load it from the buffer on the recieving end, and then reshape it accordingly

#

numpy supports np.array.tobytes and np.frombuffer to go between the two, but you'd have to specify the datatype when loading it from the buffer

#

And when converting to bytes, it doesn't preserve the shape, so loading from buffer always results in a 1d array, you'd have to reshape to a 3d or 4d array (depending on the image format)

waxen cradle
#

Say I want to port forward my socket server. Is there a easy way to do this on mac. Im using Visual Studio btw.

steady horizon
waxen cradle
steady horizon
#

what is your binding function

#

i mean what IP are you assigning

#

in socket.bind

waxen cradle
#

Yea

#

Its just localhost

steady horizon
#

and the port number?

waxen cradle
#

65432

steady horizon
#

try
gethostbyname(gethostname())

#

instead of "localhost"

waxen cradle
#

Alright, give me a sec

steady horizon
#

these are two functions inside the socket module

waxen cradle
steady horizon
#

print it out
it should be a global IPv4 on Windows 10 machines

waxen cradle
#

I got "127.0.0.1", which I believe is the localhost

steady horizon
#

Really? Well that's unfortunate. Try using this script:

from json import loads
from urllib.request import urlopen
with urlopen("http://ipinfo.io/json/") as response:
    print(loads(response.read().decode())["ip"])

to get the IP.

waxen cradle
#

Do I create new file and run it?

steady horizon
#

If you want to.

waxen cradle
#

In the virtual machine

steady horizon
#

Yeah, you could.

waxen cradle
#

Alright give me sec

steady horizon
#

And just save it somewhere.

#

I mean, save it in your client file.

waxen cradle
#

Got this "54.167.60.102"

#

Only issue is that I dont think the port has been forwarded

turbid zenith
steady horizon
#

I use urllib since it is a standard library and it doesn't require you to pip install requests.

turbid zenith
#

I think requests is a standart library

steady horizon
#

Like honestly if you don't want to use requests just use urllib. They're the same except urllib is a standard library and you might need to import or do more stuff, just like how I did from json import loads to load the JSON of the response.

steady horizon
turbid zenith
#

I never installed it and I allways have it

#

idk if maybe a third party program installs it for me or something

waxen cradle
steady horizon
#

Maybe another library you use has required requests.

waxen cradle
#

Im only using threading and sockets

steady horizon
#

from there, there should be a login possibly and port forwarding is probably at advance settings

waxen cradle
#

I tried ipconfig, but this is a bash terminal

steady horizon
#

are you connected to your machine?

waxen cradle
#

yeah

steady horizon
#

or are you just looking at the files

#

and using like a terminal

waxen cradle
#

At the moment, I have a bash terminal opened

steady horizon
#

Okay so I've read a bit on the internet and it seems as though PythonAnywhere doesn't allow using custom raw sockets like that. It supports WSGI so you can make a web app / API and communicate data like that.

waxen cradle
#

I just read that to

steady horizon
#

Do you think you can do that or do you want to give other hosts a try? I don't know any other hosts that can host socket applications like this.

prisma cobalt
waxen cradle
#

But im not going to go through the trouble of making that just for a socket

#

Thanks so much for your help though

steady horizon
#

👍

prisma cobalt
#

@waxen cradle you can port forward your own network and host yourself you know

waxen cradle
#

I just wish I could port forward on my mac

#

But nothing works

prisma cobalt
#

your mac or your network?

#

because it is different

waxen cradle
#

My macbook

steady horizon
#

And PythonAnywhere's beginner (free) plan machines only have 1 GB of RAM and 512 MB of file storage.

prisma cobalt
waxen cradle
#

No, I was saying I can't port forward using my macbook

#

Not my MAC

prisma cobalt
waxen cradle
#

Yep

steady horizon
#

bingo

prisma cobalt
#

ok, then your not port forwarding on your mac but on your network

#

the mac is irrelavent

#

its a router thing

waxen cradle
#

True

prisma cobalt
#

i have a port forwarding guide in the pins lol

steady horizon
#

Cool.

waxen cradle
#

Ah, thanks

waxen cradle
prisma cobalt
#

what is the default gateway for you?

#

or what router do you have

#

that looks like an odd gateway

prisma cobalt
waxen cradle
#

Thats apparently how you do it on mac

prisma cobalt
#

what router do you have?

#

they should ahve a guide on port forwarding if they support it

waxen cradle
#

Let me check

#

Its called ToToLink

prisma cobalt
#

@waxen cradle try this ip in the address bar

waxen cradle
#

I actually im literally trying that right now, but it just doesnt load.

prisma cobalt
#

these are the two port forwarding guides they offer

waxen cradle
#

Let me try them

cedar forum
#

the automating way of doing port forwarding is doing the opposite

#

it's called hole punching

#

basically you have a server with a public static IP, you connect to that server and maintain a connection from the port you want to forward and then use that socket to communicate as if it were a port

#

it's how discord voice calls work

flat rain
#

Python send request to the website but got block and response back here

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>ERROR: The request could not be satisfied</title>
</head><body>
<h1>403 ERROR</h1>
<h2>The request could not be satisfied.</h2>
<hr noshade="" size="1px"/>
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<br clear="all"/>
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<br clear="all"/>
<hr noshade="" size="1px"/>
<pre>
Generated by cloudfront (CloudFront)
Request ID: FjRwM_RSiYzGEr8lK_tt3DyKqpflsX8P7jySE7LG3aycwackWP4YyA==
</pre>
<address>
</address>
</body></html>
#

**```fix
[Anyway to fix this ?]

#

DM me if you find a way

tropic laurel
#

Is there really no educational access to fortinet firmware images?

scenic prism
#

i have a client.py and server.py i want client.py to send data to server.py how to do it?

client.py

import socket
import os

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('cant show',4321))

while True:
    msg = s.recv(1024)
    print(msg.decode("utf-8"))```

server.py
```py
import socket
from tkinter import *
from tkinter import messagebox 
import os

ip = 'cant show'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((ip,4321))
s.listen(5)

while True:
    clientsocket, address = s.accept()
    print(f"Connecting from {address} has been established")
    clientsocket.send(bytes("Welcome to the server!", "utf-8"))

please halp

narrow oak
#

You're trying to receive data in the client code, and send from server

prisma cobalt
scenic prism
prisma cobalt
scenic prism
#

well obviously this server is for learning purposes not coming learnt and doin absolutely nothing

#

would have been better if you had told nicely

prisma cobalt
scenic prism
#

cmon dude

prisma cobalt
scenic prism
prisma cobalt
#

it should help

scenic prism
#

wait

#

i figured it out

#

anyways

#

thanks for giving ur effort helping me

#

cya

cedar forum
#

yeah you have to go through a central server

#

it's how stuff like ngrok works

#

generally I'd assume it is not on residential networks

#

it's probably situated on servers on the public facing internet with no need for port forwarding since there is no NAT

#

yes, generally your connection is to one server which the connects to the decentralised network

#

my understanding of crypto is limited though and I don't think it's a smart use of technology in a lot of cases

ember ledge
#

yo

#

so i made this load balancer implementation

#
import socket
import threading
import time


def serve_conn(conn):
    data = conn.recv(1024)
    new_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    new_conn.connect(("127.0.0.1", 5000))
    new_conn.send(data)
    data = None
    while not data == b"":
        data = new_conn.recv(1024)
        conn.sendall(data)
    conn.close()


server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

server.bind(('127.0.0.1', 8000))
server.listen()
while True:
    conn, addr = server.accept()
    threading.Thread(target=serve_conn, args=(conn,)).start()

#

not sure how else i would go on and do it

pulsar vigil
#

that's the default configuration of millions of routers?

ember ledge
#

um

#

its not what its supposed to do

#

its supposed to reverse proxy from port 8000 to port 5000

sick shale
#

dudes
is it possible to connect my pc to a computer outside the local scope using sockets when my isp is using cgn?

ember ledge
#

anybody use ngrok?

#

yeah

#

how does someone from the other side of the world connect to it?