#networks
1 messages · Page 33 of 1
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...
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?
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
Btw, does that also apply to a multiprocessing.connection.Listener with an authkey?
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
a proxy
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:
- if i block your first request to unlock and record the data of the request
- you press the key again, assuming your too far away or you didnt click it hard enough
- i record the second request and then play the first recorded data back to the car which unlocks it
- 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
Sorry, I didn't understand this
python is a programming language. it can't receive radio waves. you'll need a device.
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
Would anyone recommend a good error correcting packet framework?
Or would this kind of thing not even be needed with python
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
From my experience is not needed, I believe with its TCP sockets, error correcting is already implemented
anyone can help me with socket library python?
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! 
This saves the file the to the folder called logs! However doesn't send the data to the other connection?
Anyone know why?
check the pins for resources and examples
why are you printing the binary?
I was seeing if the image_data was presence.
and was it?
Yes it prints it.
I don't know why it isn't sending the data though?
show the reciving script
thats weird
whats the output when run?
like does it print file transferred correctly?
also you are sending "done" to the other file but the other file isnt recv anything
that might block your program
show me your startServer() function
your getting a TypeError
Uhh I Wanna host my own server and was wondering if this raspberry pi was a good place to start
thank you, kind person!
I've done this before with a raspberry pi 0 w and it worked fine
Hey what are pririquisites to study networking ?
@ember ledge
@prisma cobalt Any ideas?
Thanks a bunch
Socket, and scapy
Socket to understand the princip of connection, and sockets xD and scapy to understand the packets princip
Bro do u have any resources to study them ?
Not pro, ive some knowlege
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... ?
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.
Thanks ! I'll try to decode using what u said ! 👌
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
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()```||
no offense but this isnt good
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)
this should be of help @thick pivot https://stackoverflow.com/questions/27241804/sending-a-file-over-tcp-sockets-in-python
it also assumes that you will actually be able to read the full 4kib if it actually is there
No problem, i juste did that speedy, and what u Say is True, i should add an exit or sys.exit. but for the file size, how to do ?
Maybe just dont set a max size ?
Hi, I am new to networking, is it possible to connect multiple computers using socket?.
With a server in between all them, yes
linked list of computer networks 😳
How I can make my socket server always alive?
What's a good introductory tutorial/text/video to get started with networking in Python?
I feel like a legitimate dumb ass
hi guys.
two questions:
- 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?
- are there any python modals folks use for secure crt?
what do you mean?
for as long as its running "its alive"
Like it will be alive forever
for as long as you run it
I want always on :(
then keep the process running 😂
your probably looking to outsource to a hosting site
Which
AWS
Heroku
to name a few
Heroku free?
both are but AWS requires you to enter your card details anyway
Heroku then
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
Or without, a server is just usefull because u can keep it running, but u can connect ure sockets in p2p
Yeah but with "multiple computers" (more then 2) it's gets harder and harder until it becomes unfeasible lol
True xD
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?
yes, try wireshark.
but be warned, this sounds like you want to do something sketchy and/or break ToS, liking building a custom client
idk, so be warned that nearly all webtraffic is encrypted purposely to stop people reading whats going on
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?
I dont quiet understand what you're making, "a server post some basic post-file receipt analysis"?, but regardless, sharing your code could be helpful in telling whats going wrong in closing the socket
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
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
is https://tryhackme.com the one your thinking of? @primal leaf this is a good resource
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
the project I'm writing basically receives a file at the server end, then compares that file against a reference with difflib to report what's not matching
so for fixing the socket closing issue, try running the code in a different environment like the IDLE or smthng so that exact error could be know, since just pycharm reporting that the code is unreachable is'nt very informative on what might be going wrong lol
I was just mentioning.....
lol
anyhow someone helped me a bit earlier with it
anyone good with rtmp and sockets, i want to stream from python to rtmp server audio and video
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?
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
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
Oh thanks, I think I understand correctly
check the pins
the pins 
if someone made an android phone to collect the one using it, what you look first?
Hey guys was wondering how to connect to ipv4 host with ipv6 only proxy in python
Teredo?
doesn't ipv6 only mean only ipv6?
my ip is XXX.XXX.0.XXX, but in my modem settings I can only use XXX.XXX.1.XXX for port forwarding, is this normal?
for example: my ip is 123.456.0.789, but in my modem settings I can only add 123.456.1.XXX ip's
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.
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
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.
kk
k
so can I assign an Ip address to Vlan 1, then SSH to it
so the layer 2 switch itself has an address and ssh port you can connect to?
that's what i'd set up
i'd use console port
gotchja
so I'm buying a new switch for the project
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
could I still SSH to it if it isn't connected to a router?
if you put the switch and the machine running the python code on the same ip range yes
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
thank you
does anybody have a good roasts source for example a subreddit
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

why do you need ctypes
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
but why not just use the threading library to kill the thread
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 ?
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
thanks
how to create dos?
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
DoS = Felony 😉
says the person called "hack the NSA" 😂 but yeah your right lol
My name is some joke that idk why I made but 🤷♂️
lmao
But yeah idk why they’d ask how to commit a felony but people ask dumb stuff sometimes
Is it possible to run a scan over multiple ips on a single interface in parallel and be faster than a sequential scan?
May I ask what you’re scanning any IPs for…?
@livid coyote
What’s up
Open proxy ips
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
anyone?
Please stop with these fake gifts
its not .all, try import scapy or from scapy import *
website communication usually consists of HTTP requests
not sockets
it might be possible with sockets but it will be 10x easier with requests
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?
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.
a Wifi Receveiver can be usable in what context
It's not recommended to use wildcard imports anywhere as they can cause issues
The server you were connected to closed the connection
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 ?
he may have just meant disk operating system
Idk
Yeah
just showing the syntax for importing sutff 😂 the person who asked also seemed interested in importing all
Any Scapy pros? (PLS DM ME)
how to get what client sent in server, socket
Down to a low level, how do you believe that communication works?
What libraries do you believe that requests uses?
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
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.
thats what i said 😂
if i ask for ketchup at a restaurant i dont expect to be given all the raw ingredients that make up ketchup, i want the actual ketchup lol
In a way, but not in a way helpful to the kid.
i directed them to the requests lib lol
neither of us have strictly answered their question
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
quit?
code?
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?
You need to store session cookie
Where would I put the session cookie? would I use a simple add_cookie function or should I put it in the request headers?
!d requests.request
requests.request(method, url, **kwargs)```
Constructs and sends a [`Request`](https://requests.readthedocs.io/en/stable/api/#requests.Request "requests.Request").
Pff
https://docs.python-requests.org/en/master/api/#main-interface here you can see that requests.request accepts cookies kwarg
requests.get(url, cookies={"session": "id"})
See also https://stackoverflow.com/a/7164897
!d requests.Session
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]>
```...
You can try to create requests.Session object with set session cookie
!d requests.requests
Hi, other than the serial library, is any alternative for using a console cable to connect to a switch?
In python I mean
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
Is computer A and B connected, or do they share a single data source where one side makes changes and the other reads it?
wdym by "connected"?
Do they establish a direct connection with each other or is there some other data point involved. (Is the 'variable' stored in computer A?)
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
Look into sockets in python, should probably be a good starting point
was my first thought but wanted to ask here to make sure
since I have no experience with that
It probably does what you want, it's also a good starting point if u want to learn something else networking related later
And wich libs for a simple chat between 2 computer in 2 diffrrent networks ?
Sockets too?
Websockets or sockets will do the work
If you're making a web based, using websocket is want u want
And if the computers are in the same network?
Same thing, shouldn't really affect the technology being used
Wdym by "web based"
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.
Okay
!d requests.Request
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.
Why am i getting [Errno 11001] getaddrinfo failed?
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.bind((MY_IP_ADDR, 5000))
😭
whats the code
oh wait
thats the code
um... idrk
That is the code
yeah ik
idk how to solve it
sry
😭
:jk:
jkjkjk
1234567889
123456789
0123456789
ill shut up now 🙂
...
🙂
whats the ip your trying to use?
its probably wrong
my external ipv6
hmm
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)
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
Do you have a tutorial or something ?
if your trying to accept traffic in your server script, use the ip 0.0.0.0 which will accept connections from anywhere
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
There r some pinned comments in this channel that has some resources
once youve got connecting two computer down, read the source image in byte form, send the bytes of the socket, write it to a new file on the target computer
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?
The request error can be caused by:
malformed request syntax, invalid request message framing, or deceptive request routing.
Try modifying your input in a more appropriate form and repeat the request.
I finally figured out the error which is similar to this page but there is no answer
https://stackoverflow.com/questions/44330748/how-to-comply-with-policy-defined-in-wsdl
Yeah so SOAP is like, really strict. If you're getting a validation error and it doesn't make sense, the SOAP server doesn't care. I recommend trying different types in your request and just play around until you find out what data type is really expected
After an entire day debugging, I think this soap service doesn't work with Python. Bumner
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
Thats not a solution
I may transfer 500 mb
Tell a permanent solution
For all kind of things
I cant seem to access my local django server for some reason
https://stackoverflow.com/questions/68325629/not-able-to-connect-to-django-rest-server-at-http-127-0-0-18000?
I have used the same code as the tutorial on the
drf website
When i run
python manage.py runserver
it gives me this in the terminal
Watching for file changes with StatReloader
Performing system
you can request specific files like .png with files='pn'?
csrf = client.get(url).cookies['csrftoken']
I tried this but it dint work so idk how tograb the csrf token
the response
why are you trying to do this exactly
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
thanks
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/
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?
I don't think so (that you can use open), you should check API for your cloud
Which cloud are you using?
I dont have any
im doing this for the summer jam this year, so I am NOT willing to pay
You can use AWS free tier or Dropbox?
smart, is google drive also an alternative?
Ofc 🙂
is there any api wrapper for it?
I don't know, never used it, I have seen API for Dropbox, there should be also one for Google Drive and so on
k ty
👍
Can somebody please tell me what I am doing wrong: https://stackoverflow.com/questions/68346282/valueerror-string-length-does-not-equal-format-and-resolution-size
Please I am entirely desperate
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||
No, because you are going to be rate-limited by Discord's API for editing the embed so rapidly.
Well we could change the source and leave the end link the same 🙃
That... idk... honestly
Is there a database of sorts that can handle images really well?
You will probably need to refresh the channel or click the image again or something though idk
not that i know of
and it's not the right channel to ask that question in
🙁
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
How do you plan on updating the source?
I might have been talking bs, cuz I clearly have no clue what I'm talking about
@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
The closest solution I found was to use imgur, but I can't even figure out how to upload an image
😭
you can use https://pypi.org/project/imgur-python/
I did just that I'm a total noob at this
Might be true, but that never stop people might trying yeah, after all it's all just a believe
Thanks for ur time tho
here is info that seems important to you: https://imgur-python.readthedocs.io/en/latest/image/
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 😂 ||
Thanks..
good luck bro honestly
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
Or, you can make a game with PyGame or something, and publish it on Discord's game store.
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
??? Bump
Please I am in desperate need of help
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?
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
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?
?
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
?
Haha, yes, just got the answer from a diff server
Device takes precendence
But I have a feeling my hostnames are not getting resolved properly
I can't use dig Im runnign android
oh you mentioned linux
I can test it on Linux, but the issue is on Android
though there must be networking tools/apps for Android
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?
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
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.'
"some reason" is in the latest line
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
try changing the post to a put
I got help in #🤡help-banana, thanks! url needed to be https;//temp.sh/upload, and yeah post had to be put
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
how can i fix that ?
code normally fully correct so idk why it doesnt work
so does someone of you know how to fix
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
except socket.error as msg
thx
?
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
it looks like your sending the pings lol, then receiving the echos
can i post home networing questions in here?
A guide for how to ask good questions in our community.
is there any way i could use the socket module to connect to another private ip / wifi router or network
You can connect to every device which is accessible - you cannot connect with devices behind NAT for example
so i cannot connect 2 routers together?
as obviously none of them are public
You can but you need to configuration them properly
oh
is there any documentation or tutorial on that?
Idk, I had exercises like this during studies
where did you learn it from?
During lectures
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.
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
I've been learning about some network programming and so far I have found libraries/frameworks like gunicorn, gevent, flask, django etc useful. idk if these are helpful for u but check them out
Yeah sure I'll check these. Thanks a lot.
@regal pendant have also found request module useful if your network device has an api. You can also check pysnmp
hi, im new programming in python. Can someone tell me why in line 22 "random" it isnt correct?
Import random
I have used websockets in flutter with a backend server written in python, and it did the job. I reccomend working with web sockets though over sockets, especially for mobile apps and websites
Sure I'll check pysnmp. Basically I want to manage them through SSH.
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?
the gethostname method returns your computer name which can be used for local network communication instead of using a local ip
your right in saying it cant be used for external network communication (over the internet)
and can i use it as a domain name like google.com?
no
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
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.
hmm isnt that against google ToS 



I hope not
Guys asyncio ia best for handling multiple connection and data or default socket
Is there anything I should include in the post request besides url, user-agent and request payload data?
Go to inspect element on the side you're visiting and click networking, then refresh and you'll see what headers your request contains
Not all of them are important but good to know in case
I just made a server side using python using websockets library. it can communicate to dart code but now I need to know how to make a standard wsgi callable to deploy it using gunicorn. any idea about that?
btw thank u for that I didn't read it message until now but I did what u said lol

😦
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()
how can i host my bot 24/7 wihout leaving pc 24/7 rasp pi or paying
need help
Need help guys! I'd like to write a python script to kick unauthorized users off my WiFi network. How should I implement this?
idk what kinda bot it is but heroku may help u. Google it
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
Not networking related but you can’t mix grid and pack, choose one or the other (I recommend grid)
Try a hosting service like aws or heroku
What do you need help with?
This is a port scanner, there are countless examples on google if you need a reference
@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
Looking for a pretty dumbed down resource for programmng sockets TCP/IP sockets in py. Any resources for my little ol brain?
How to get the services running on the ports
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?
You can use socket.io to emit data from server to client
@clear bobcat so basically the option is sockets not the standard way of doing flask apps with routes ?
Afaik if you want to have bidirectional communication you cannot do it with pure Flask 
👍
you should check quart out. it's pretty good framework to work with websockets and also similar to flask so you don't have to learn it
interesting. never heard of it... thank you, will check it out 🙂
@rose oxide any notable advantages/differences between quart and flask?
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.
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
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
cheers mate good luck to you too 🙂
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()
is this a good place to ask questions about http?
it certainly is
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
Nice but could you explain the start() function
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?
use web: python <your python_file>
also it assigns port dynamically so u need to configure port as
import os
PORT = int(os.environment.get("PORT", 5000))```
5000 will be default port if it doesnt find PORT variable
: at=error code=H14 desc="No web processes running" method=GET path="/"
also
what do I set as host?
ummm how r u deploying it?
like gunicorn or something?
no
python main,py
gunicorn is wsgi
I am running an Asyncrhonus socket.io server
"asgi"
I have used asgi server like hypercorn to deploy my async websockets
could you help me in depth step by step?
it worked well for me
I used quart framework btw which is similar to flask but asynchronous
actually I'm not familiar with aiohttp but I can try
if I stop lagging ffs
kk ty
I have now tried using uvicorn
There is one thing that is stopping me now
what is it
deploying the thing...
It runs with uvicorn on my local
but when I build it
I get no unbinded port error anymore
what address do you provide for host?
0.0.0.0
no wait I use default
but I think default is 0.0.0.0
and port like this?
yes
127.0.0.1?
that's local host most of the times it's the default
so better configure it to be 0.0.0.0
yea it's fine just make sure you bind it properly
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
maybe your app is using default port that's why it's causing problems. check if you can somehow bind it to the port that heroku provides like if there is a way to run uvicorn using python code it'll be good
otherwise u can use hypercorn and make a python file then run it using python
sorry my internet sucks ass today
I think it works

ight
nvm it doesnt work
I think its because heroku thinks that a HttpResponse is supposed to be returned
but it aint
any errors on log?
umm I don't think so if your program runs and connects to clients it should be fine
found the problem
turns out the file was never run at all
because of there was no running dyno at all

Sorry my bad
lol make a new account I guess
although
or buy dynos
try it then
Hey guys, I need help making a multi-client heartbeat system
I am able to connect and stuff
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?
ayoo gg
it doesn't have to know just connect to URL
ok
if it's websocket try using ws://
that helps a lot probably
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
it is
then it should work
Hi, did any of you ever tried algo trading?
did only auto!
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.
question, can you get stock market data from heroku
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
U need (on a linux cputer) to anable port fowarding, using the folowing shell command => echo 1 /proc/sys/net/ipv4/ip_forward
And sysctl -w net.inet.ip.forwarding=1 on macos
Use the same command with 0 to disable
is this not possible to do on windows?
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)
@vagrant wasp
haha okay I'll look into using linux for future projects, thanks for your help 🙂
Ure welcome !
I couldn't find schema for pymongo?
Isn't there one?
See #databases
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
https://pgjones.gitlab.io/quart/tutorials/websocket_tutorial.html
this is the link to documentation if needed
Port forwarding is a router thing is it not? @vagrant wasp try going to your router settings
I ws talking about enable it on ure own computer. Enableing it on the router is made same... on the router x)
But they wanted external connections to work lol, they already got local connections working
In which case you need to change the port forwarding rules on the router
Right, i ws just talking about htd, but u can do it where u want xD
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)```
hello ,
can we made something.py for blocking website on the network?
and list connected devices on the routers? ( same network)
I learned the hard way that my isp doesnt like port forwarding on residential routers lol, I forwarded a port and it made my router not work for 2 hours, it was a long phone call with my ISP fixing it. I ended up just using a cloud server, had to rewrite a bit of my server for it but in the end it worked
Ooo unlucky, what ISP do you use? It's weird tho, most big ISPs offer port forwarding as a feature instead of hating it
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
That sounds really good, can I get a link 😄
Ofc you could have used another site like aws which would allow you to run it 24/7 for a year for free
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...
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 🙂
hey
so im tryna make requests via http,socks4/5 proxy
using socketserver
does anyone here know how to do it
maybe see this article: https://www.3cx.com/blog/voip-howto/stun-details/
As seen in a previous article, STUN protocol plays an important role in VoIP implementations: to discover the presence of NAT and to learn and use the
Please tell me like socket implementation of it
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
yeah sorry i cant, it's a complicated setup, not something you can just copy paste and do easily with raw sockets
not sure why you need that in the first place tbh
I want to understand underlying protocol so I can make my own protocol
based on NAT transversal
Also I am trying to counter symmetric NAT
then reading is your friend 🙂
yes🥲 There is no good article about it
reading scripts day and night
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
yes it does but it doesn't explain how it works behind the scenes any developer who want to work with WEBRTC would be fine with it
hmmm...
after all It's just echoing out IP/PORT
that would defeat the entire point of a protocol
hmmm...
I am just angry why peer to peer doesn't have a uniform implementation over networks
p2p decreases every aspect of load to server
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...
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.
for a gmail account, yagmail is probably your best choice: https://github.com/kootenpv/yagmail
Well, it seems good x)
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
Thanks !
Should I use select or threading?
Most tutorials on YouTube use a threading mechanism of some sort, but I also discovered that select can be used for asynchronous socket programming.
select lacks an example on docs.python.org
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.
@steady horizon Instead of using raw select you can use higher-level asynchronous I/O.
asyncio has some primitives for working with sockets
Hm. Thanks. I will look into asyncio socket programming.
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
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...
hi
can you use a wifi analyzer to see the mac address of a wifi access point.. without connecting to it
what exactly is https://docs.python.org/3/library/asyncio-sync.html#asyncio.BoundedSemaphore I read this already https://docs.python.org/3/library/asyncio-sync.html#asyncio.Semaphore
and since BoundedSemaphore() will be deprecated soon what should I use instead
Deprecated since version 3.8, will be removed in version 3.10: The loop parameter.
@ me if you can and want to help
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
you will need a static ip for it to work
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
noip is pretty good too
does that require to open some ports or something?
Yes
Thought they are gone
opening ports one's personal network doesn't really seem safe lol
Have not heard of a way to get remote login or desktop without opening ports
yeah so you need to open ports for that
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
lmao you can help them set it up 😂 pass on the knowledge
dam this idea is getting old lol
yee the knwoledge should live on
lmao
Ssh port is open port ed
yee indeed, but I'm talking about opening ports on the EC2 instance
Then i have no idea
lmao
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! 🙂
does websocket and socket related questions belongs to here?
ye
hello..i need help.
my task is to block websites on network
on the same network!!
( not using hosts file)
websockets are high level compared to generic sockets. like websockets is an application layer protocol like http. But sockets are end points for communication (IP+PORT)
blacklist it on ur router ?
using python
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
try the requests module, very easy and they support modifying headers
well... you might struggle using ports 0-1023
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
I used requests already, and I'm tryna learn how to both make a faster request, but also learn how to use other modules relating to making requests yk
@prisma cobalt hello mr networker
lmao @prisma cobalt got some fanboyism goin on lol, count me in 🤣
Lmao
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 ?
Well, a fk*** DoS ?
I think using socket is better, but require a bigest knowlege of how it works
@fierce pivot I guess requests lib is using the socket under the hood.
Yeah, i ever searched how resuests works, and it uses urllib, that use socket. Well, socket is the low level networking and every apps are using sockets, module, or just sockets x)
yeah, correct. But my question more towards usage of requests lib 🙂
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
for sake of discusion lets assume, requests happens in short period of time.
how it can be optimised for TCP overhead ?
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
Ok, I guess https://hyper.readthedocs.io/en/latest/quickstart.html helps in such case .
Although, project is no longer maintained.
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...
Core networking concepts are Ethernet, IP and TCP/UDP for me 
for generic networking on a wide range of topics, picking out bits of the CCNA that interest you proved fruitful for me https://study-ccna.com/
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.
thanks guys!
Anyone have a good document describing application headers to use with TCP communication? It is my first time designing an application layer for that.
You write your own headers.
You are supposed to plan how messages look and build a protocol from that.
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.
well, a good starting rule is you don't want to have redundant information in there
you're optimising for size, primarily
Understood. Thanks for that. I will go ahead and sketch something out
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.
check out the channel pins
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 😦
How to convert subnet mask to vlan mask... Someone explain it PLz..
vlans and subnets are two completely different things
so you'd have to elaborate what you want to do
you may want to look for Set-Cookie header.
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
well, if theres an error stating that the port is being used - thats most likely the case..
👀 big brain
Well, HTTP is on TCP and its headers are basically X: Y and it knows where a header ends with a newline character, so it's basically a normal looking list of X: Y
data then begins on two newline characters, and ends with two newline characters
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?
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)
Say I want to port forward my socket server. Is there a easy way to do this on mac. Im using Visual Studio btw.
Host, run, and code Python in the cloud: PythonAnywhere
Ive made an account and tried running the server.py, but it throughs an error Cannot assign requested address
and the port number?
65432
Alright, give me a sec
these are two functions inside the socket module
Yes, its working. But how do I know what IP I should use to connect to
print it out
it should be a global IPv4 on Windows 10 machines
I got "127.0.0.1", which I believe is the localhost
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.
Do I create new file and run it?
If you want to.
In the virtual machine
Yeah, you could.
Alright give me sec
Got this "54.167.60.102"
Only issue is that I dont think the port has been forwarded
one question, when to use urllib and when to use requests?
I use urllib since it is a standard library and it doesn't require you to pip install requests.
I think requests is a standart library
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.
Nope.
I never installed it and I allways have it
idk if maybe a third party program installs it for me or something
@steady horizon, I cant seem to connect, I think it might be because the port hasnt been forwarded. Is there some way to do this?
Maybe another library you use has required requests.
Im only using threading and sockets
Maybe. Try opening a command prompt and run the command: ipconfig
Copy the IP of the Default Gateway and paste it in a web browser.
from there, there should be a login possibly and port forwarding is probably at advance settings
I tried ipconfig, but this is a bash terminal
are you connected to your machine?
yeah
or are you just looking at the files
and using like a terminal
Linux ipconfig equivalent
At the moment, I have a bash terminal opened
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.
I just read that to
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.
port forwarding a local network is usually a router thing, not a device specific or IDE thing
But im not going to go through the trouble of making that just for a socket
Thanks so much for your help though
👍
@waxen cradle you can port forward your own network and host yourself you know
My macbook
And PythonAnywhere's beginner (free) plan machines only have 1 GB of RAM and 512 MB of file storage.
so your only connecting to your mac from your mac?
what are you trying to do? host a server and allow connections from outside your network?
Yep
bingo
ok, then your not port forwarding on your mac but on your network
the mac is irrelavent
its a router thing
True
i have a port forwarding guide in the pins lol
Cool.
Ah, thanks
Yeah, my router has never been able to work like that though. Whenever I enter the default gateway in, it says site could not be reached.
what is the default gateway for you?
or what router do you have
that looks like an odd gateway
?
Thats apparently how you do it on mac
what router do you have?
they should ahve a guide on port forwarding if they support it
I actually im literally trying that right now, but it just doesnt load.
Let me try them
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
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
Is there really no educational access to fortinet firmware images?
i have a client.py and server.py i want client.py to send data to server.py how to do it?
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
You're trying to receive data in the client code, and send from server
try learning sockets before copy pasting code from websites that you dont know what it does
i just send the copy pasted data coz my program is a lot bigger and it would have been difficult to explain my issue, anyways people judge a lot these days
what? i meant you clearly dont have a basic knowledge of sockets and this code is copied from a website somewhere
learn sockets first, and then if something goes wrong we can help
well obviously this server is for learning purposes not coming learnt and doin absolutely nothing
would have been better if you had told nicely
your not coming to learn though, if you were coming to learn then you would have followed a resource and not copied code that you dont understand
if on this off chance you are coming to learn and have approached it badly then sorry and heres a brilliant guide
https://realpython.com/python-sockets
dude i didnt copy the code its the basic line and tht aint my code in my application.. mine is different
cmon dude
its not your code lol?
.send() sends data and .recv() receives data
both need the other to work
which youd know if youve looked at this https://realpython.com/python-sockets
yea ik i have been trying to receive data in server.py but i dont even have an idea bout receiving
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
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
that's the default configuration of millions of routers?
um
its not what its supposed to do
its supposed to reverse proxy from port 8000 to port 5000
dudes
is it possible to connect my pc to a computer outside the local scope using sockets when my isp is using cgn?