#networks
1 messages · Page 24 of 1
most things use websockets, which essentially create a server on the client and use that
Is python or html best to start?
totally depends on what you want to do and if you prefer frontend or backend, but this is not the right channel.
Whats the right channel for beginners sorry to ask here
Hello everyone.. what is the best way to write a python code which verifies if tab completion is working fine in a router
hi is there a way to host without port forwarding
need a clear explanation of
what is a header
in api
Not really I don’t think
I don't know if this question is relevant, but for some reason when I boot up Linux (Ubuntu), it does not connect to my wifi adapter (TP-Link T4u) at all. It is not broken as it works perfectly fine when I boot it up to Windows 10. My guess is the adapter is not not compatible with Linux or the driver is outdated.
have you installed a driver
how to make python client and server side so i can screen it to a port and connect via putty
yeah the windows driver won't have anything to do with linux
i imagine you'll have to look for a driver for that wifi card yourself
looks like they have a linux installation guide
Okay so I'm following the instructions and it's telling me to install 'make', and for some reason, its saying that 'make' has no installation candidate.
have you run sudo apt-get update
that makes sure you actually have a package list available locally
are you connected to the internet
No
that's why I'm trying to get a driver
since my wifi adapter doesn't work with Linux
your trying to get a driver for your internet adapter from nowhere, you have to connect to internet to install it i believe
Actually that might work
or ethernet surely
Hi Guys
I recently started using the sockets library
But I have some doubts
The first one is:
I want to create a program that has a server and a client
In the server
Will be a Sqlite3 database
And I need to the client can acess it
But, I don't know how can I send a message from the server specifically to the client who sent a specific message
Does anybody knows how to do this?
hello, im wondering where can i learn the basics or the fundamentals of networks and networking
@dreamy kelp It works! Thank you so much, I have been trying to configure my WiFi to Linux forever.
You're welcome!
@lusty forge What's your wifi?
Like, what's the chip?
if it's broadcom you'll guaranteed get help from me
Since I've dealt with broadcom chips before in Linux
It's a TP Link T4U
I'll look into it
On a side not, why does Linux go hay-wire with certain wifi adapters?
Is it because some adapters are closed source?
Super new on python... Tips please, I know some networking and have some computer skills but I need to know at least one lenguaje program and I have decided that phynton is the one
Youtube has a lot of content but sometimes is overwhelming and you kind of get lost
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I want to create an API for Authentication in Flask is there any tutorials or articles can you suggest
any ideas how I could test that proxies work? I wouldn't want to ping google for example by testing each proxy
hello, can anybody please explain to me how I can send a signal to 2 raspberry pis over wifi?
establishing communication and sending signals for i/o
for example if a button is detected on first raspberry pi it sends a 1 or a 0 to a second raspberry pi
@ember ledge you can create a custom protocol in windows by modifying the registry
look up x-scheme-handler or whatever equivalent there is for your system
I built a little script that kinda give me some control over what devices connect to my Access Point.
The original goal was to get message notifications when someone I knew connected, like a door bell when friends drop by but with a text.
It works ok seem to have a few issues.
I’m looking for more ideas to add to this script I feel like I’ve only just begun making a AP device manager, there must be a million things I could do I haven’t thought of and I’m looking for input if anyone has an idea to add.
This is what it looks like right now
Whats the most optimal family and type for sending larger transmissions of data over a socket
can anyone tell me if im doing this formula right?
n(n-1)/2 n = 4
4(4-1)/2
4(3)/2
12/2
6
looks good to me
Hello, anyone knows how to write logging to shared network files?
Has anyone worked on building a rtmp server in python?
how to not send traffic through vpn in python with socket with udp protocol?
yep!
Gentlemen: What's the go to message delimiter/framer package in python? Zmq? A way of transmitting complete message frames over inet without building up from sockets.
With the requirement of no external message broker service, or being limited to web-requests. Just a sanity-wrapper around TCP
Maybe some big brainer could help me set up my router to allow connecting to other devices on the network? ie. connect to a server on the same network using it's private IP address
@ember ledge I have an Archer C7, trying to telnet to a TCP server running on another device but I can't, can't even ping it.
Not sure how to proceed 😄 I'd be happy to hop on voice and share my screen and go through the settings
Do u know how to bind something like on server, ip port etc?
Yep
Everything that's server-side I can manage, the particularities of networking escape me ;D
Yeah, on LAN
It's my desktop running a TCP server and trying to connect from a windows device on the same network
Uh, u need to bind user
I can help u
With conn
Ill write code for conn on user
It should work
Nono, this should be networking specific, the same server works on the network in my office
Same OS, same everything, just different network
@modest fulcrum what do you mean can you be more specific
Hello I'm trying to get an old Zelda the golden Kingdom server started for some friends and me. I used these files here:
https://github.com/LostSoulFly/Zelda-Golden-Kingdom/tree/Testing
The thing is when I try to start up the ver .70 server I get the runtime error 339: Component RICHTX32.OCX or one of its dependencies is not correctly registered.
I tired to search for the file but cloudn't find it.
The other thing is when I try the starter.exe it always says "Please run this program as an Admin" even if I'm running it as one and with my kaspersky security disabled.
one friend managed to get around the "RICHTX32.OCX" problem but then I think it needs a DLL setup or smth idk really.
ik its very late but thank you!!
im an engineering major wanting to do something interesting in my break
Is python socket programming platform independent?
does it use winsock or unixsocks?
most of it a OS independent because the dependant stuff is usually under the hood
but there are certain specifics that can change between OS for example Asyncio's event loop supports and selectors
yeah definitely be aware of os differences
but the concepts involved in sockets and most of what you write can be platform agnostic
Hey can I find someone who can assist with my secure decentralised backend?
I'm working on and off on it
But I'd like to pick up the pace a bit more
1. s.bind(("",9000))
2. s.bind(("localhost",9000))
3. s.bind(("192.168.2.1",9000))
4. s.bind(("104.21.4.2",9000))
- Lets any connection bind to port 9000, 2. let's only the local host to bind to port 9000, 3. let's only 192.168.2.1 bind to port 9000, and 4. let's only 104.21.4.2 bind, to port 9000.
Is that correct?
no, the first element in the tuple is what address to bind to
i.e. serve on
so localhost serves only on the local computer
192.168.1.x (your LAN ip) serves only on the local network
and 0.0.0.0 binds on all interfaces
what does that mean
it will accept connections from everywhere, effectively
any way a packet could get to your computer, if you're listening on 0.0.0.0 you will get that packet
I thought "" meant it accepts connection from everywhere
so does 0.0.0.0 have the same effect as ""?
Yes.
For IPv4 addresses, two special forms are accepted instead of a host address: '' represents INADDR_ANY, which is used to bind to all interfaces, and the string '<broadcast>' represents INADDR_BROADCAST. This behavior is not compatible with IPv6, therefore, you may want to avoid these if you intend to support IPv6 with your Python programs.
So then is what I said for IPv4 or IPv6?
"" and "0.0.0.0" both only work for IPv4, and mean exactly the same thing.
Is there a place where I can learn networking? I've just been wandering the internet and I'm not sure which resource I'm supposed to use
Well I just completed a course in college on it. Try "Kurose and ross: Computer networking A top down approach". You'll learn the Networking layer by layer. 7 layers that is. This book is great. And also try these videos, I guess they could help, it did to me 🙂 https://www.youtube.com/playlist?list=PLo80JwUm6hSSwGLJmS_quaeJgx9SILLiI
Hey @astral smelt!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
I need help with VOIP project. I was able to do a one way communication. I want to be able to do it the two way. Idk how to use threading to make it possible, I've tried it but I don't have much experience with it and hit a wall. I'll add client and server code for one way.
#client
import socket
import pyaudio
chunk = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 10240
host = 'Local netwrok IP address' #enter your Local netwrok IP address of the machine that is running the server.py code
port = 50000
size = 1024
p = pyaudio.PyAudio()
stream = p.open(format = FORMAT, channels = CHANNELS, rate = RATE, input = True, frames_per_buffer = chunk)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
print ("Connected!! You can now speak")
while True:
data = stream.read(chunk)
s.send(data)
s.recv(size)
s.close()
stream.close()
p.terminate()
#server
import pyaudio
import socket
chunk = 1024
pa = pyaudio.PyAudio()
stream = pa.open(format = pyaudio.paInt16, channels = 1, rate = 10240, output = True)
host = 'Local netwrok IP address' #enter your Local netwrok IP address of the machine that is running the server.py code
port = 50000
size = 1024
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((host,port))
sock.listen(5)
client, address = sock.accept()
print ("Server is now running\n=======================")
while 1:
data = client.recv(size)
stream.write(data)
client.close()
stream.close()
pa.terminate()
you need to make a definition for listning to audio and a def to send audio, then use threading to start both threads, as you recieve data you should play it
Thank you.
can anyone plz help me with http.client module requests to get the root document of a webpage?
@hoary sorrel ?
I'm gonna go to bed soon, but I can try for a minute. It's usually preferable to use the requests package from PyPI instead, as it's much easier to use
ill look into that
guys, how can i see the status of a port that isnt on my current ip? i mean, on windows, running netstat, shows the ports linked to current ip. But i know for other ips there are other ports oppened
yes, and i know cuz i opened some port for some games, but my pc ip is dynamic and it changed
i use to have it static, but idk why i swapped it
i'm kind of new to sockets and server programming. Is there any way I can use AWS to set up a server that's always listening by uploading some python code?
Also do you guys know any good resources to learn more on this topic
i remember doing this for a C2 server. upload a listening socket script on the cloud and ssh into it to execute commands
@blazing axle what do you want the socket to listen for? I.e End Goal / problem you are solving ?
How am i able to find the port that is connected to the certain ip i am looking at?
receive_thread = threading.Thread(target=receive_server_data).start() send_data_to_server()
Could you explain what this block of code is doing?
How am i able to find the port that is connected to the certain ip i am looking at?
@subtle scaffold
S = socket.socket(socket.AF_NET, socket.SOCK_STREAM)
Hostname = s.gethostname()
HostIP = s.gethostbyname(Hostname)
Please correct me if I'm wrong. I'm new to socket programming.
have to create a videostream with live capibities that outputs different results based on "type" of user that is watching
could you please elaborate on this
@kind furnace essentially the goal is to output a video stream with different overlays based on whos watching
@astral smelt do i just put all of that into a ide?
@subtle scaffold
You must be aware why I took the "s" variable.
Now try "host = s.gethostname()" and print the host variable. You'll get bunch of stuff, in which you'll also be able to see the port number and the IP address. Now, s.gethostbyname() used to get the IP address only. Google about both of them, gethostname and gethostbyname method.
ok tysm
Hello Team
hope you are all well
I need help to make little python program
I have 3 list
u = ['a','b','c']
v = ['a','b','c','d']
w = [1,2,3,4,5,6,7,8,9,10,11,12]
and I need below desire output
output =
a a 1
a b 2
a c 3
a d 4
b a 5
b b 6
b c 7
b d 8
c a 9
c b 10
c c 11
c d 12
do we have any trick in for loop ?
import socket
server = input('server: ')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def pscan(port):
try:
s.connect((server, port))
return True
except:
return False
for x in range(1,26):
if pscan(x):
print("port",x,"is open")
else:
print("port",x,"is closed")
@astral smelt afters some research this is what i came up with
i made a successful port scanner based on user input
what do you think about it?
Hello guys.
I am working on some docker containers, Where there is a "main" nginx host that then proxies to other nginx hosts
server {
listen 80;
server_name mcaq.me www.mcaq.me files.mcaq.me dev.mcaq.me priv.mcaq.me;
location / {
proxy_pass http://mcaq:8080;
proxy_redirect http://mcaq:8080/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
This (above) is the main nginx container
server {
listen 8080;
index index.html index.php;
server_name mcaq.me www.mcaq.me;
root /code;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
This (above) is an example of one of the sub-nginx containers
The main nginx server is being controlled by certbot after running, so is actually listening on 443 ssl
This behaves as I expect, when connecting to https://mcaq.me
Then, when going to https://mcaq.me/portfolio, it breaks
It shows the 8080 port, which I don't understand
If you instead do https://mcaq.me/portfolio/
It works as expected
I've tried different things like using proxy_redirect, but I am struggling to find a solution, or understand what the problem is
Any advice, or if you need more infomation, let me know. cheers!
i made a successful port scanner based on user input
@subtle scaffold great, can you share it with me? Just DM me, if you could
yes i can do that
Networking is just the general term for making two processes talk to each other over a network... Like whenever you want to access a server over the internet, for instance.
Hello i'm having a Error with my program. i'll leave the source code if needed.
Its saying
File "mac_changer.py", line 25, in <module>
change_mac(options.interface, options.new_mac)
AttributeError: 'NoneType' object has no attribute 'interface'
```
Leave source code
there
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
please tell me why the error occurred too.
@subtle scaffold
nvm i got it
Hey @hollow yarrow!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
#bot-commands
I want to write an application for my bluetooth headset, how can I do this to check the charging status
qcy t5 model
I just want to confirm the arp command in the cmd. Basically, it used to identify the IP and MAC addresses of the devices on your network which mean u know who is on the network? Correct me if I’m wrong
I am using sockets to create a chat application
but i am getting this error "OSError: [WinError 10049] The requested address is not valid in its context" when i put in my public ip
protect how
do you want to encrypt it so it cant be spied on?
spyed
spied
who knows
Want a challenge during the Holiday season? Participate in the New Year Solve, where you get the opportunity to solve this year’s most groundbreaking challenges. From the world of Health, to Climate to Finance, participants can choose one category and create a solution that can help millions. If you want to read more about these categories, swipe to read on how technology is impacting these sectors! Compete for a prize pool of $50 with your friends all from the comfort of your own home. And you heard it right, t his is completely FREE! https://forms.gle/i4q3iAkJjvopyGru7
World of Devs is hosting its first-ever competitive event called The New Year Solve! Competitors will be given the opportunity to choose an ongoing/current problem related to Health, Finance, or Climate/Environment. Once they have identified a problem, their task will be to create a solution that can be implemented through technology (coding, ro...
huh?
A client socket? You just use sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) to create a new UDP socket, then ```
sock.sendto(b"some message", ("1.2.3.4", 12345))
Yes but I don’t want to recv any packets, I only want to send out packets
The code above only sends packets and never receives any.
But when I do sock.recv(99) it recieves the packet
If i don’t release it the memory will grow larger and larger
Release what? How?
recv creates a new bytes object. If you keep it, it takes up room. If you keep a lot of them it could take a lot of room...
Also you said you don't want to receive any packets, then you said you're calling recv... I think I'm missing something here.
when someone send me a packet, the system will capture the packet and store it somewhere
and if I don't use recv frequent enough, those packets will build up in my system
how do I tell the system to drop all packets that is sent from someone?
Have you called bind()?
Then it shouldn't even be possible to receive, AFAIK. I don't think you can receive UDP packets if you never called bind()
yes you can
idk
lemme test that
yeah
yes you can
I just tested it
using sento() will give you a port
Yes, it does, but you shouldn't be able to receive on that port.
That port is open for sending only.
hm, nope, I'm wrong. I just tested, you can receive on that port.
TIL
well, alright, general knowledge then: the maximum amount that could ever be sitting around waiting for you to recv it is the size of the socket's receive buffer. By default that's probably about 200 kb, if you're on a Unix system, and you should be able to shrink it further using setsockopt to set the SO_RCVBUF option - the minimum on Linux appears to be 128 bytes.
I don't think there's a way to completely remove the receive buffer for a socket.
guys, anyone with understanding about game serving with python?
i have my game idea ready, just need a server
saw some tutorials but nothing is making me understand
I do understand the very basics, ip:port, sending and receiving information, the problem start with the loops, how to interpret the messages sent and received
I think there's a method to flush the input buffer without needing to worry about storing the receive data although you could just call recv and not assign it to anything if it fails once the buffer fills up
I have to learn about networking for my exams :()
Would you guys suggest getting my Comptia network+ cert
hello everyone I am looking for help in my python project, can anyone guide me ?
is there a pre-written library for clients to send images to server w sockets?
Hi guys, I have aws t3 medium centos machine. I have installed jenkins on that machine and it is running. But i am not able to access the jenkins on my local browser using : http://publicipofmachine:8080. Can someone please help in this
@main fable have you opened your IP firewall to that port?
@late pike why do you need to use sockets?
because its between a client and a server and I already have that set up with sockets
The purpose of the code isn't just to send images
but also images
I don't think there's a specific library, but it isn't too difficult to do with the sockets module specifically. Have you tried that?
I tried, I encoded the image to base64 and tried to send it to the server. But I got confused when having to calculate how many bytes do I want to recv
but yeah I think I can do it myself
I was just curious if there is such a library
I don't think there is, but I'm sure you will be able to find a example to help you. I can have a look for you if you need a hans
Hand*
msg = 'Thank you for connecting'
client_socket.send(msg)
```This gives warning Expected type 'bytes', got 'str' instead
Why not str though?
Because the TCP layer expects you to hand bytes to it, and there are many different ways to encode a str to bytes. Rather than guess which of those ways you might want to use, Python is making you be explicit about it.
UTF-8 would be the most common choice these days. If that's what you want, you can do client_socket.send(msg.encode())
so is b'' and encode('ascii') same thing?
b'' is an empty byte string. encode('ascii') is a method call you could make on a string to encode it into bytes according to the ASCII encoding. If the input string was empty, it would generate an empty byte string.
b'' is equivalent to ''.encode('ascii') - though the empty string is encoded the same in every string encoding, there's nothing special about ASCII
alright thx
You almost certainly want to use UTF-8 instead of ASCII
Unless you know you need some specific other encoding, UTF-8 is by far the sanest encoding to default to these days.
can anyone help me fix the error. idk what went wrong
I want to send image data over sockets. Can I just do this:
image = open(dir,'rb')
and than serialize it using json?
.
You don't need to use JSON at all, unless the remote that you're sending to expects JSON. You can just open(some_file, 'rb') and read the file with .read() and send those bytes over the socket
But I can store the .read() contents in an object, serealize the object, send the object to the remove, and then unserealize at the other side?
What do you mean by "serialize"? If you need to use JSON, it makes things a little bit more complicated.
JSON doesn't have a way to represent binary data, so you'll need to encode the binary data into some text format like base64 before sending it, and the receiver will need to know to undo that transformation.
I have an app written in python that sends items over a network (shopping items). I want to keep things object wise simple, so packing everything into an object, including the image would be really nice
@hoary sorrel
like I said, then, you'll need to encode the binary data as text before JSON encoding it. So, something like:
import base64
import json
image_file = "some_file.png"
with open(image_file, 'rb') as f:
image_bytes = f.read()
image_base64_text = base64.b64encode(image_bytes)
message_dict = {"image": image_base64_text}
message_json = json.dumps(message_dict)
sock.sendall(message_json)
and then the remote side would need to do the reverse of that - deserialize from JSON, extract the "image" key, deserialize from base64 using base64.b64decode(), and then it has the raw binary bytes of the image again, which it could write to disk or whatever.
@hoary sorrel nice! thanks! If I recall correctly, json only takes dicts to serialize? If you pass custom object, object.dict() return will be used?
I'd be very surprised if it used obj.__dict__ instead of obj.keys() and obj[key], but I'm not positive.
!e easy to find out...
import json
class C:
def __init__(self):
self.x = 10
def keys(self):
return ["a", "b"]
def getitem(self, key):
return 42
obj = C()
print(obj.__dict__)
print(json.dumps(obj))
@hoary sorrel :x: Your eval job has completed with return code 1.
001 | {'x': 10}
002 | Traceback (most recent call last):
003 | File "<string>", line 11, in <module>
004 | File "/usr/local/lib/python3.9/json/__init__.py", line 231, in dumps
005 | return _default_encoder.encode(obj)
006 | File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
007 | chunks = self.iterencode(o, _one_shot=True)
008 | File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
009 | return _iterencode(o, 0)
010 | File "/usr/local/lib/python3.9/json/encoder.py", line 179, in default
011 | raise TypeError(f'Object of type {o.__class__.__name__} '
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/burivolexo.txt
nope, looks like it doesn't even use the mapping protocol, it just expects a dict.
that makes sense, considering the way it has to handle recursion.
So I will have to write a method manually to go from object to dict and from dict to object?
In my example above, I didn't have a method for that - I just did message_dict = {"image": image_base64_text}
I guess you could make that a dedicated method, but I think it depends a lot on what else you're trying to do.
I have an item object that stores some other data too, so would be handy if I could create a dict from the object and vise-versa with ease
well, you can. in the case of your image, you're just setting one key in the dictionary to a base64-encoded version of the binary data of the image. If you want to do that in a dedicated function, you can.
@hoary sorrel thanks! you're awesome
@hoary sorrel may I ask another question?
sure
I want to be listening for a server reply constantly except for when I want to send to the server. I already did research, is it true that it would be best to use non blocking sockets?
yes - unless you know that you'll only send to the server at specific times, in which case you could get by with blocking sockets with a timeout set.
Thanks, my academic python course did not even mention sockets 😑
you may find that asyncio is the easiest way for you to do what you're trying to do, FWIW
Any asyncio socket lib that you recommend?
I know asyncio basics, but no real asyncio socket lib
I see, asyncio has support for sockets inplemented
https://docs.python.org/3/library/asyncio-stream.html would be the easiest stuff to use, I think.
@hoary sorrel but can I use sync socket server side and async client clientside?
yep; the client and server are completely independent - how one of them interacts with the socket doesn't affect how the other one does.
nice! thanks a lot! I am restructuring my entire project. Just so it becomes a bit cleaner. You're the best
import socket
import threading
host = "0.0.0.0"
port = 1337
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host,port))
s.listen(100)
print(f"Listening on: {host}:{port}")
clients = []
def commander():
while True:
conn, addr = s.accept()
print(addr[0] + " connected!")
command = input(">> ").encode()
conn.send(command)
while True:
threading.Thread(target=commander, args=()).start()
hey, im trying to do that it'll require me to enter a command everytime
but it does just once
any ideas?
@ember ledge so once you entered a message and it has been send the script stops right?
ya
maybe you can add a statement for is_active in the def commander before calling your first while True. So it nows something is still active and the script shouldn't close unless that is set to inactive what you call when the client disconnects from the server. Add the is_active = False in the beginning and then go is_active = true. If this doesn't work you can always use the "Try" function
do you have a server running for your chat system?
ye
Do you have a receive function so you can see each others messages?
ye
while True:
data = s.recv(1024).decode()
print(data)
i just need server.py continue to send messages
not just stop once its sent
Remove the while True from threading.Thread(target=commander, args=()).start(). maybe this works
il send you mine maybe you can use some parts def sendmessage():
while True:
if stop_thread:
break
message = f'{nickname}: {input("")}'
else:
client.send(message.encode('ascii'))
receive_thread = threading.Thread(target=receive)
receive_thread.start()
write_thread = threading.Thread(target=sendmessage)
write_thread.start()
Hi Guys! I am network engineer and wanted to learn python, I am a complete noob in python ..Just joined python discord channel can someone advise me on where to start? Thanks
I would suggest here: https://www.tutorialspoint.com/python/python_networking.htm
Given that I literally just started teaching myself python yesterday and this is where I learned about networking: https://www.tutorialspoint.com/python/python_networking.htm
Python - Network Programming - Python provides two levels of access to network services. At a low level, you can access the basic socket support in the underlying operating system, which allo
I built on top of the code they provided.
Sweet..Thank you @molten abyss
I would suggest asking this question in one of the help channels found in the Available Help Channels category
(ie. #help-croissant)
or in #discord-bots
Ok man thanks
On that note; Would anyone happen to know how to create a new thread when a connection has been established on a python server?
Basically, I am trying to get my server to handle multiple client requests asynchronously
you "establish a connection" by getting a return value back from your call to sock.accept(). Once you get one, you can spawn a thread to handle that connection, or handle it off to a pool of worker threads that were spawned using concurrent.futures.ThreadPoolExecutor for instance.
Yah, I found out that I have to use threads. I now need to figure out how to adapt my code to permit threading. I don't have perfect formatting, as I taught myself python yesterday, which is what is making this so challenging 
it's a great language to know. keep at it 🙂
Hey @queen herald!
It looks like you tried to attach file type(s) that we do not allow (.exe). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .webm, .webp, .flac, .afdesign, .m4a, .csv.
Feel free to ask in #community-meta if you think this is a mistake.
Pls @ me if you know thanls
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
Hey, I'm having issues with using proxies and the requests module
requests.get("http://ip-api.com/json/", proxies={'http://': "username:password@ip:port"} )
When I make that request it still outputs my ip, thanks
Does requests have any way to restrict a url to a certain domain
parse the url yourself and verify it before doing the request?
yeah ok just wondered if there was some like
well
completely prevent it from making requests outside of a domain
but this works fine i guess
Hey! i'm new here.
you could do something like register your own adapter for http:// and https:// that returns an error, and one for http://the.domain/ that uses the default HTTP adapter - but, that'd be more work than just parsing the URL yourself, and doesn't really buy you anything.
howdy
thanks
is my understanding of the following correct: the total number of IP address available is called the IP Address Space (about 4 billion of these). These are then broken up into 3 major groups (i realize there are 5 and not 3) class classes, Class A, B and C. Each class has a certain number of IP address in them. Each of the classes is then broken up into further subgroups called networks which each holds a certain number of IP addresses?
that was correct, once upon a time, but Class A, Class B, and Class C aren't really a thing anymore, and haven't been for decades.
now, a network is defined by an IP address and a subnet mask, instead of the size of the network being implicit based on the class.
the architecture you're talking about was https://en.wikipedia.org/wiki/Classful_network, which existed until 1993.
oh ok but the concept still applies?
as in the ip addresses are broken up into networks which are then broken up into subnetworks?
like an IP address with a subnet mask for 255.0.0.0 is in the network (group) of 255.0.0.0?
i guess i mean the network that are represented by the first octet*
The subnet mask tells you how big the network is. 255.0.0.0 tells you that the first 8 bits of the IP address (the entire first octet) are part of the network address. So if an IP address like 10.1.2.3 has a subnet mask of 255.0.0.0 it belongs to the 10.0.0.0 network, which includes 16777216 possible addresses. If it has a subnet mask of 255.255.255.0, then it belongs to the 10.1.2.0 network, which contains 256 possible addresses.
gotcha gotcha and that's for subnet masks with 255 or 0 ---> refers to the network. The subnets with says 255.255.252.0 means the network represented by the first 2 octets and the subnetwork of the next 6 bits?
because 255.255.252.0 = 11111111.11111111.11111100.00000000?
right. so given an IP address like 253.253.253.253 with a subnet mask of 255.255.252.0, the network address is 253.253.252.0 (because 253 & 255 == 253, and 253 & 252 == 252)
No - I meant what I said.
255 . 255 . 252 . 0 is the network mask
253 . 253 . 253 .253 is the IP address. You get the network address by bitwise-AND'ing these things together.
SO the network address is:
(255 & 253) . (255 & 253) . (252 & 253) . (0 & 253)
which is 253.253.252.0
hmmmmm
i understand the first 2 octets
isn't the subnet mask just a map for which bits are responsible for the network ID or the subnetwork ID and which are for the Host ID?
right - the third octet, 252, is 11111100 - so the first 6 bits of the 3rd octet of the IP address are part of the network ID, and the last two are part of the host id. And all of the last octet is part of the host id.
ok gotcha and since it's only 6 bits and not 8 bits it gets a special name of subnet right?
like subnet ID
no - not really. "subnet" is short for "subnetwork", which is a term that you were already using earlier.
Network A is a subnetwork of network B if network A's host address range falls entirely within network B's host address range
so, 10.1.0.0/255.255.0.0 is a subnetwork of 10.0.0.0/255.0.0.0
because 10.1.0.0/255.255.0.0 contains host addresses from 10.1.0.0 through 10.1.255.255, and 10.0.0.0 contains host addresses from 10.0.0.0 through 10.255.255.255, and everything in the first set falls inside the second set
or, to put that a different way, network A is a subnetwork of network B if it has more network mask bits set than network B, and if you masked off those extra bits you would get network B
is that making any sense?
!e ```py
import ipaddress
a = ipaddress.IPv4Network("10.1.0.0/255.255.0.0")
b = ipaddress.IPv4Network("10.0.0.0/255.0.0.0")
print(a.num_addresses)
print(b.num_addresses)
print(a.subnet_of(b))
print(b.supernet_of(a))
@hoary sorrel :white_check_mark: Your eval job has completed with return code 0.
001 | 65536
002 | 16777216
003 | True
004 | True
if you were to chop 10.0.0.0/255.0.0.0 into 256 equal sized chunks, one of those chunks would be 10.1.0.0/255.255.0.0, so 10.1.0.0/255.255.0.0 is a subnet(work) of 10.0.0.0/255.0.0.0
hmmmmm
i think it does hang on
ok i got that par
part*
basically something with more 1's in the subnet mask is the subnetwork of something with less 1's in the subnet mask right?
i.e. 255.255.0.0 is a subnetwork of 255.0.0.0
you also need to consider the network address
well yes
then yes, as long as you realize that.
assuming the network addresses make sense
like 192.x.x.x is not a subnetwork of 10.x.x.x regardless of the subnet masks right?
if the two networks are equal up until the shorter of the two network masks, then the one with the longer network mask is a subnetwork of the one with the shorter one.
like 192.x.x.x is not a subnetwork of 10.x.x.x regardless of the subnet masks right?
right.
hmmmmm
that makes sense then
it is a bit tougher to visualize
but it's better now
thank you very much @hoary sorrel
know much about port forwarding?
yeah haha i drew something like that on my notebook when trying to explain it to myself
that shows how each time you add one new 1 bit to the network mask, you effectively divide the old network into two new ones.
(each half the size of the old)
sure, I know some things about port forwarding.
ok so essentially i have a server program on my raspberry pi. i managed to connect to it from my laptop using a client program (all programs written in python). The whole point of this is to then have the server run another prgoram that controls my servo motor (that's already written)
I then realized the only reason i was able to connect to the server using the ip addresses that i used in the programs were because they are both within the same LAN and that if my laptop were not connected to the same router, then it would be trying to access the server on my rpi from the WAN
because, again, the whole point is i want to connect to this server from anywhere in the world, so port forwarding is a possible solution to this?
the architecture goes: press a button on an app that i create (from anywhere)---> sends signal to server on rpi that's always listening ---> server starts the program to control the servo
well, yeah, but - doesn't sound like a good idea to do that, unless you're very confident or very careful. If anyone anywhere in the world can send input to your script, and there's any type of input to your script that could cause the servo motor to overheat, or things like that, you can cause physical damage this way.
but yes, configuring your router to allow inbound connections on port 9000 (or whatever) and send them along to your RPi's port 9000 when they come in will work.
ok yeah so plenty of people have told something to that extent of being careful. Is that because i'm basically exposing that port to the world unprotected?
you're achieving exactly what you said you wanted to do, allowing anyone in the world to connect to that port on that machine and send whatever they want to it. So, how will your program handle it if 100,000 computers connect at once? Or if they send you invalid messages? or if they tell your servo to spin as fast as it can for as long as it can? or if the Linux kernel running on the raspberry pi includes a vulnerability in its TCP stack that allows someone making specially crafted TCP packets to cause it to execute arbitrary code?
hmmmmm that makes sense, so how can i limit it so that only i can access that port from anywhere in the world?
¯_(ツ)_/¯
build some sort of authentication system and be very convinced that you got it right.
at that point you're into security territory, not networking territory.
that actually makes a lot of sense
i'll reflect on that going forward, thanks man, i appreciate your help. Is there any way i can like rate you or something? I'd like to give you 5 starts or whatever is the max
or maybe a mod you want me to put in a good word for you?
is SHA1 hexdigest save to use?
I send the hexdigests over tcp connection where they are stored in yaml.safe_dump files
safe as in free of collisions?
Generally no (known attacks against it), but unless you're the target of a nation state, you're probably okay.
and if you are the target of a nation state then for the love of god get out of pydis #cybersecurity and #networks
SHA1 is pretty trivial to force, even if you aren't working on a really sensitive project you shouldn't use it
yeah depends on what you mean by 'safe to use'
if it's for the same purpose as md5 then like
ok
MD5 is considered crypto secure though, isn't it?
MD5 carries the same trivial force issues
too fast to make hashes with and massive lookup tables make for ez brute force
Fair enough
for checksums just use one of the sha-2s
Hello. can anyone tell me how to make the most basic multi user chat prompt?
Is this possible with command prompt
I am creating a MUD engine and part of that is allowing users to see each others text input.
I need to have a working multi user environment as soon as possible. Any idea how long it would take to make it coding 8 hours per day?
probably very dump question, but is there a data limit on tcp sockets in python?
data limit how
I have constructed a giant dict consisting of multiple images in base64. Can I sent them over tcp without problems?
how giant
and why not use http to get rid of some of the painfulness of large transfers
if they're really large
ah right
Assuming that the connect, isConnected, and disconnect functions work as intended, could someone explain why this function won't execute the second print statement if the client fails to connect to the server?
def test(self, port):
conn = connection()
connected = False
print("connecting...")
server = conn.connect(port)
connected = conn.isConnected()
conn.disconnect(server)
print(connected)
return(connected)
Better yet, here is the connect function:
def connect(self, port):
server = socket.socket()
server.settimeout(5.0)
host = socket.gethostname() #Might not be a bad idea to put into a config file
print(f"host: {host} type: {type(host)}")
print(f"port: {port} type: {type(port)}")
server.connect((host,port))
connection.conn = True
return(server)
thanks! you're awesome

does it give you an error
It just gives me a connection refused error
on the server?
On the client. I'm basically doing a port test.
well it failed to connect so it raises an error
hmm
Ah, I see what you're saying. Sometimes I forget that my application doesn't crash since it's linked to a gui
Ok, so I need to do a try,catch then
yeah, just catch that specific error
Would you happen to know the error? ie, what to put on the except line?
you can catch whatever error it throws
so in this case probably something like sockets.ConnectionRefused
ok, so that's not the attribute
in that case, i know that TypeError is built in
So it's a typeerror?
not in your case
my example was to show that i tried the error behaviour
saw that i got a typeerror
Oh, I know
then knew to catch a typeerror
ah so the error class is ConnectionRefusedError if that's what the error message said
however
it's in the sockets module
annoyingly python errors don't actually tell you the namespace of the error
ikr
let me look a sec
im seeing from stackoverflow that socket_error will work
Is a raspberry pi zero suitable for a tcp socket server? What are your opinions?
Now if only I can figure out this buffer problem >.<
Then I'll be finished with my CTF 😄
ikr
so what's the buffer problem
I tried changing the buffer size, but that didn't work
are you sending more than 1024 bytes of data
cause it will wait for the timeout if it doesn't receive enough
but i thought it doesn't error with the timeout
just returns the data you wanted
ah right so why is the timeout a problem
what goes wrong
uh
hold on
Screen: login
host: DESKTOP-293494 type: <class 'str'>
port: 12345 type: <class 'int'>
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1884, in __call__
return self.func(*args)
File "C:\Users\user\Documents\Python\CustomCTF\client\start.py", line 149, in <lambda>
login = Button(window, text = "Login", font=32, padx = 10, command=lambda: loginHandler(eUser.get(), ePass.get(), result))
File "C:\Users\user\Documents\Python\CustomCTF\client\start.py", line 172, in loginHandler
response = log.check(user, password, server)
File "C:\Users\user\Documents\Python\CustomCTF\client\login_client.py", line 19, in check
rec1 = s.recv(2048).decode()
socket.timeout: timed out
weird i didn't think it errored on timeout
huh
ah ok so
set the timeout as 0, then if no data is available you won't receive any but if that happens you can just check next time
also be aware you can't necessarily guarantee that the data will arrive in a sensible way
Except the fact that it times out every time
if you transmit the username then password, you'll receive them all at once
yeah but if you set the timeout to 0 it will keep the waiting data until the next call
i think recvline is a thing
or recv_until
so you could use newlines to delimit your data
and transmit username:password or something
so here's this code snippet:
#success = False;
s.sendall('login'.encode('utf-8'))
#while not success: #Loops through until successful login
if not user or not password: #Fail-Safe
#print("Please enter a username and password.")
return(("Please enter a username and password.", 0))
#continue
s.sendall(user.encode('utf-8'))
s.sendall(password.encode('utf-8'))
rec1 = s.recv(1024).decode()
rec2 = s.recv(1024).decode()
Lets say that the 'login' message gets send, then the user ("John") gets sent.
What happens is that the server receives them concatinated, "loginJohn"
*shock
sock.send("Hello")
sock.send("Hi")
``` is the same as ```py
sock.send("HelloHi")```
Even if I have 2 receivers?
yep
shock
cause the first call tries to read 1024 bytes of data
whatever that is
it has no idea that two python function calls have caused the data to be written

I actually have quite a bit of rewriting
Also, how does one split text at a character?
ah
ty
I started learning python 2.5 days ago, so I don't know all of the syntax yet
2.5 days ago
thank god lol
noice
The most recent release
lol
python 2 is disgusting
Comparing the code, it's just like ... what is this, C?
b/c python2 has a lot of similarities to C, ngl
imo python3 is like python2 but less worried about being a proper programming language
so they fully support unicode strings by default
bytestrings are different
raw_input vs input
just a load of sensible changes that get rid of the ways in which python 2 tried to be non pythony
It's so funny. I used to hate python, mainly because I hate R, and I had to use Python for my AI class, which I hated.
ah rip
we get a lot of data scientists here
maybe """""""""""""data scientists""""""""""""""""" is more appropriate
But man, now that I am doing networking, python is so fun
good!
I'm not a data scientist and I hope to never be one
Though a good portion of my major is data science
Even if it's only high level
you say that
I will probably, never in my life, try to interpret and transform a csv
tru
@storm saffron Let's say I do: split = "msg".split(":")
Will this throw an error?
no, afaik it will return ["msg"]
lte me test it
yeep
also note that
which is a bit interesting
if you're not expecting it
Oh ye, u learn that in intro to CS
ah nice
It's the way an array is set up
|0|1|2|3|4|5|
Like that, and the | is the edge case
ah sensible
i've never really learned programming in a class
the practical parts at least
yeah
well
pointers are easier in C than python cause in python if you're doing mutability then that's fine
but the moment you start wanting to thinking about pointers to things it becomes a lot more tricky
Yah, @storm saffron I'm still getting the timeout error
grr
I think I actually made it worse 👀
Oh wait, hold on. Sorry, I think I know what's happening
Sorry going to bed atm, feel free to DM me if you have any more questions about this
I'll answer when I can
kk. Np
Is there anyway to print the origin of the request? Using request module
Can someone please tell me a cheap way to host a Flask project temporarily?
@native oar idk maybe ```py
import socket
import request
#Howwever there is defintely a better way, because theis just gives you the IP of the current machine the script is running on
me = socket.gethostbyname(socket.gethostname())
imma do more research on this

You want the requester's IP address?
How do I send an instance of a class from a server to a client using sockets
I meant pickle*
since the other end has to know exactly how to turn it into an instance of the object at the other end
ah right
well pickle still isn't great because it's very insecure
I don’t mind
if your program is unpickling everything it gets sent, anyone can run any code they want on your computer
Like with what I have right now
I don’t mind
Because it’s just for a school project
With what I have right now all I am sending are basic strings
when my client connect to one another they each get dealt a different instance of my ‘card’ class
But I want them to all have been dealt cards from the same deck
I don’t know what to do to my code in order for them to be dealt cards from the same deck
Host, run, and code Python in the cloud: PythonAnywhere
hey, does anybody know something about upnp sockets?
can I make amultiplayer game with python
maybe a fps game would be cool, but i dont know any networking libraries or resources
are there any good resources for game networking?
Is it possible to transport data from javascript to python through an open socket?
And when I say possible, I mean feasible
I know it's doable on node, but idk about normal js
Yes what is you question
If anyone codes in Raw Sockets. I am particularly working on editting IP headers, and generating correct checksums.
Somebody please help
Are you talking about generating random values from the same list?
Anything on Networking and codding sockets in python3 hmu because i do client socket coding.
Heres a trick to easily send encoded strings in python3
import socket
destination_addr = 10.1.1.1 # What u want
Port = 15 #Open UDP Port ( Any )
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Str_send = input("Data to send> ")
s.sendto((bytes(str_send), (destination_addr, port))
Thats how u easily send encoded strings in python3
Hey guys how can I block making requests to a domain from my PC? But I want requests to go when I use a proxy.
I tried blocking domain names in /etc/hosts. But it is blocking proxy requests also.
Iptables
Is it possible to block a domain name using iptables?
If yes, will I be able to make request to that domain using the proxy from the same machine/container?
Its not that complicated, just enter the terminal in which your domain is hosted and run the command. This will block any data targetting the domain via that has been blacklisted
You dont have to scrutanize the /etc directory and it will save you time
there is some issue with this command.
getting this iptables v1.6.1: no command specified
sudo apt-get install iptables -y;
Yeahh and I want them to get dealt cards from that same list
https://paste.pythondiscord.com/gitafujiko.apache the client side of the code
https://paste.pythondiscord.com/ebigapiceb.py the server side of the code
https://paste.pythondiscord.com/afupapaper.rb the network which I use to connect my clients to the server.
Can somebody share the basic code for client.py and server.py for connecting 2 devices?
I'm very new to networking, I've tried visiting certain websites,repositories but none worked for me
Any help would be appreciated
Pls guys help me out
Not really sure where to ask this so please point me to another channel if this isn’t the right one.
I’m building a scraper for a website. This website has the following section in their ToS:
You agree not to use or launch any automated system, including without limitation, "robots," "spiders," or "offline readers," that accesses the Service in a manner that sends more request messages to the servers in a given period of time than a human can reasonably produce in the same period by using a conventional on-line web browser.
Am I correct in assuming that scraping is allowed as long as it does not send more requests than a normal user would? If so, how many requests would you say a normal user can reasonably send?
Generally its such a blanket term its risky regardless of what you use as the number
1 request meh sure
but other than that its pretty vague for a reason
A request a second? A request every 5 seconds? I’m not so much concerned about the legal side of things as I am about upsetting the website devs and having my IP banned.
Please guys have look at this question
what are you actually asking
like 1 request, maybe a minute or smth lol
If it's a static site, you can use Github Pages
Also, what IP address should I use to connect two computers via sockets? I tried using my public IP address, but the external client produced an error that the target machine (this computer) actively refused it, I'm assuming that this is because of a firewall. How should I get around it?
Also, one of the computers is connected via wifi, the other s connected via ethernet
Hmm, looks like my firewall isn't turned on anyways, yet it's still blocking connections.
I restarted the server, but I'm getting OSError: [Errno 49] Can't assign requested address with the public IP
I changed the IP address to my local IP address and I can get the server running now
and the client works!
🥳
whats the default type of auth in requests?
the requests module?
you need to port forward at your router
by default your router drops all incoming packets that aren't part of an outbound connection
How can I make a multiplayer game
in python
using pygame
and some networking thing
library/module
I know some basic networking stuff
but i dont know where to get started
and help is appriciated
thanks
have you made a game in pygame already
@ember ledge default appears to be http basic auth
if by default, you mean this requests.get('https://api.github.com/user', auth=('user', 'pass'))
though there are many other ways of authorization
such as oauth and jwts
thank you
How can I connect two devices using py?
I need the basic code for client.py and server.py for reference
@light zealot you can go here: https://www.geeksforgeeks.org/socket-programming-python/
Thanks!
😄
hi, does anyone have experience with pfsense ?
if so please @ me, i have been trying to figure out why my network gets really high ping when downloading something.
i have tried using queues /limiters and the same issue comes
it did get to a point where if i was downloading the ping was fairly ok (about 50ms when pinging to google) when i usually get about 15 without any downlaods going on
but when i joined a discord voice call as an example, ping went really high
have been trying for days, have no luck, if anyone could help or knows anyone who can i would be extremely great full, thanks
what network tech do you have? DSL, fiber, cable..?
cable
will be getting fibre in about two weeks
im thinking i might as well get a dream machine pro...
sorry for the late reply, if you do respond to me @ me im kind of inactive here XD
Yea I also had the same question, I did like it the instruction but when I run the code, it simply don't find the other user
Do you have an idea what could be the problem?
If you can show me the code then I may be able to figure out why it's not working
Sure
Server code:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
port = 12345
s.bind((ip, port))
print ("Socket binded to %s" %(port))
s.listen(5)
print ("socket is listening")
while True:
c, addr = s.accept()
print ('Got connection from', addr )
Client code:
import socket
s = socket.socket()
port = 12345
s.connect(('import socket
s = socket.socket()
port = 12345
s.connect(('192.168.1.47', port))', port))
I think it a firewall problem because when I run the codes on 2 cmd, it works but if I run it on 2 different pc, it never finds the other port.
All of the computers have to be on the same local network
Yea ik that
We are on the same network
Both are passing through the same router
True
Here
I found the problem
It that Windows Security blocks the connection
Now how do I do so that it won't block my connection?
change your firewall settings
Yea but when someone wants to use my progamme, they won't go and close their firewall in the settings
I want to be able without going in the settings
I want it to ask for access
Or I was wondering to try to create a path with 2 clients and one server going through the internet
it does automatically
windows will show that prompt if it hasn't been shown before
if it didn't show for you then you must have clicked 'no' for python.exe before
Aside from creating a common interface, did WSGI also fix the speed problem with older CGI-compatible servers?
A long time ago, servers invoked scripts for a dynamic response upon each request using standardized header names in the environment variables, should the script new access to them. (CGI is what standardized the header names). The problem with these servers is that they were slow, each time a script was called, the interpreter had to restart.
What I'm trying to figure out is if the systems of servers delegating requests to the Python web frameworks without having to restart the interpreter (the thing delegating the requests was already using python) was specified in WSGI, or if that was what already happening, and WSGI only standardized the interface between the two?
i wasn't aware that wsgi specified anything about how the framework works
What do you mean?
Ok thanks
did WSGI also fix the speed problem with older CGI-compatible servers?
For python -> Not really, WSGI came around because there was a lack of a interface that allowed you to pick and mix frameworks and servers
which was pretty limiting because what ever framework you picked could only use it's supplied server without any room to be reused which made it hard for developers both maintaining and developing with the libraries
The idea of having a single web server and just processing it via the framework had been around before wsgi
WSGI just made a more pythonic interface for frameworks and servers to interact allowing you to say roll with Flask and UWSGI but then maybe switch out to Flask and Gunicorn without rewriting your entire program
Converting to "int" failed for parameter "pep_number".
Python currently boasts a wide variety of web application frameworks, such as Zope, Quixote, Webware, SkunkWeb, PSO, and Twisted Web -- to name just a few [1]. This wide variety of choices can be a problem for new Python users, because generally speaking, their choice of web framework will limit their choice of usable web servers, and vice versa.
By contrast, although Java has just as many web application frameworks available, Java's "servlet" API makes it possible for applications written with any Java web application framework to run in any web server that supports the servlet API.
The availability and widespread use of such an API in web servers for Python -- whether those servers are written in Python (e.g. Medusa), embed Python (e.g. mod_python), or invoke Python via a gateway protocol (e.g. CGI, FastCGI, etc.) -- would separate choice of framework from choice of web server, freeing users to choose a pairing that suits them, while freeing framework and server developers to focus on their preferred area of specialization.
@gloomy root thanks!
I can't find this anywhere online but what happens to the server when it gets a request but never sends a response? Does it hurt server performance?
well that depends on a the server
it'll timeout eventually regardless as most clients implement a timeout as well as the server
I see, is there a way to close the connection on the server but leave the client hanging?
Ah. It's just that I've been thinking about a way to detect spam requests and make it seem like the server is down
But keeping all those connections open ins't good I see
well it depends on the server
at the packet level, if you just never send any packets back that's fine
but trying to implement that with a server like flask is impossible without tying up serving threads
so you're better off doing it in sockets
A tarpit is a service on a computer system (usually a server) that purposely delays incoming connections. The technique was developed as a defense against a computer worm, and the idea is that network abuses such as spamming or broad scanning are less effective, and therefore less attractive, if they take too long. The concept is analogous with ...
Hey, I'm having a small hiccup in trying to set up a git server with Apache. I have a test repo on my server, but attempting to clone it gives a 403 error. There is some documentation about how to do this, chiefly at https://git-scm.com/book/en/v2/Git-on-the-Server-Smart-HTTP. The issue I'm having is, I think, a result of how my domain is set up. I decided not to set up my git server at <domain>/git, but instead at git.<domain>. I also host my personal website at this domain. This means that I have two directories named <domain> and git.<domain> in /var/www/html. I also have two .conf files, <domain>.conf and git.<domain>.conf in /etc/apache2/sites-available. The <domain>.conf file is pretty standard, as is the git.<domain>.conf file, with the exception of the inclusion of these lines:
SetEnv GIT_PROJECT_ROOT /var/www/html/git.<domain>
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias / /usr/lib/git-core/git-http-backend/
I suspect that the issue is in either the first SetEnv or the ScriptAlias, but I'm stumped. I have confirmed that the issue is not with file permissions, and changing the / in the ScriptAlias to anything else causes a simple repository does not exist error. I have also confirmed that the test repo is functional, as cloning it via SSH works completely fine.
<domain> is just a placeholder for the actual domain, as I have yet to implement any security, and don't want to reveal an insecure domain.
Pardon the essay but I’m dying.
rip
i think this probably isn't the best place for this question
try #tools-and-devops or maybe a more specialised server
I’ve tried every programming-related server that I’m in.
I guess I’ll try #tools-and-devops though.
how would i connect to a raw connection type
what do you mean by "raw connection type"?
OK - so that's just any sort of TCP socket at all. That just takes whatever characters you type and sends them directly to the remote without any translation, and prints out any characters sent by the remote without any translation
yep
would i connect to this using socket
and also how would i login and execute commands
@hoary sorrel
you'd need to implement your own server, with a login protocol that you devise, and a syntax for executing commands
Raw is the type of connection you'd use in PuTTY if you bind your own TCP server socket that's accepting connections. Whatever the user types into PuTTY would just be sent as data to that server.
That server can then do whatever it wants with what the user has typed in.
cause im making it into a api
apis generally operate over http
which tcp is not necessarily
tcp is just sending a packet of bytes
whereas http has method, url, all sorts of stuff
which generally makes it much more suitable for a relatively low speed api
hm
as in you wouldn't use http for a realtime FPS multiplayer protocol
but you could use it for chess
HTTP is a particular application layer protocol on top of TCP. You could build your own application layer protocol for your API, but that makes things harder for your clients, so you wouldn't want to without a good reason.
what's the purpose of the api
i mean hey
could always build a fast network gameplay with http/3 now
wouldnt be quite as fast as raw UDP sockets but its close
wait http/3 is a thing
yes
damn i'm so behind lol
i'm only just beginning to accept that http/2 is something i need to be aware of
http/2 but implemented in the UDP protocol
Its very new but has alot of potential with speed
Currently only supported by Chrome for browser
Firefox will probably get it when the h3 crate is production ready
what ip should the client be connecting to and which ip should server bind to?
like public/private for each one
ping me if you end up answering
i have to send 50 messages
hey guys, i have a domain called electric.sh. is it possible to have a subdomain or something like get.electric.sh?
whats this for?
this is for my flask api
If you are planning to use the connection outside of your local/home network, use your public ip for both. Otherwise use your private for both.
If your domain service allows Dns management I think you can by making a record and point it to your page site with get. At the start so it's like get.yourip.com
thanks : )
Np hope I helped.
can someone help me with port forwarding
what should I fill in the 'External Source IP Address'?, my public IP, right?
It's offtopic, not related with Python
Discussion on network protocols, technologies, hardware with relation to Python
You can try in offtopic channels
okay, sorry.
just let them ask @clear bobcat , this is hardly the most active channel and people are more likely to know how to answer here since its #networks
someone here helped me with MY portforwarding before
hey what are debian mirrors ?
Mirrors are copies of something
So they are links to copies of the Debian package repository
does someone know how to sniff tcp packets with scapy?
can someone go to #help-chestnut
what ip address for a server allows it to be hosted on the router, not just on the host device?
wat
so if i use the ip 127.0.0.1 (which is the ip for localhost, which is scoped to just my device), what can i use so it is scoped to my router
You can use 0.0.0.0 to accept connections on any interface.
How do I turn off any firewalls on my Python script?
Im doing some networking stuff, and I think my windows defender broke something
Anyone feel like helping me at #help-chili?
Hy all! My name is Marius Avram and i am CCNA certified trying to learn python for network automation. Glad to be here.
Willkommen
I'm not sure what I'm doing wrong here, I'm not receiving any data. Probably missing something obvious here, could someone help point it out please?
Thanks in advance!
in s.recv(1024) you might need to decode the message try doing s.recv(1024).decode() . im not sure if im right because im still pretty new to this stuff.
This was the problem, thanks for your help!
you welcome glad i could help!!
I actually have a problem with my script too. I am trying to make a simple messaging app thingy on the command line but i am not able to send one clients message to the other. I tried using multithreading but i have no clue what the bug is. Help would be greatly appreciated.
these are my scripts
Hey @tall mesa!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
@tall mesa Your client has to wait for you to input something before recieving anything from the server
@tall mesa There are a few solutions to this. Threading or asyncio are both good options, where you can have the bit that deals with input not block the bit that deals with network communications
You could also figure out some way to do a timeout on the input, or use a GUI platform that does the threading for you behind the scenes
Hey, does someone know how can I detect when someone connects to my Wi-Fi?
Check your router or AP's arp table
almost all routers have it prominently displayed in their web GUIs
If you are just trying to stop people from connecting to your wifi, you should set a strong password. MAC filtering also gives some protection, but can be defeated if anybody can get the mac address of anything on your network.
where should i start w/ networking?
please ping on reply
Yes please suggest the foundation required for networking
What do you actually want to learn
IT/infrastructure, low level protocols, security, hardware?
or specifically to python
Specifically to python
before learning networking specifically to python you should literally learn networking
but if you want you can give a look to the scapy module, used for packets interception
i just started networking last week and i started with sockets and threading. is that a good place to start?
async def get_guildlist(self, data):
listt = [self.bot.guilds]
return listt
Why doesn't this work? The page is just loading and loading
hey
can someone tell me how to make a public chatroom(which can be accessed by people outside my router) .
i already know how to make a local chatroom but i cant find any video to make a public chatroom
you need to port forward on your router
@storm saffron is there any other way to do it or is that the only way?
well the alternative is host it somewhere else
but at the end of the day you have to allow packets to get to the server
yep
thank u
i am have a problem with sending my client messages
import socket
import threading
HEADER = 64
PORT = 5555#the port we want to setup our server in
SERVER = socket.gethostbyname(socket.gethostname())#gets the ipv4 adress of wifi
ADDR = (SERVER, PORT)
FORMAT = 'utf-8'
DISCONNECT_MESSAGE = "!DISCONNECT"
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)
messages = []
def handle_client(conn, addr):#this will run for each client seperatly
print(f"[NEW CONNECTION] {addr} connected.")#prints adress of person who connected
username = conn.recv(2048).decode(FORMAT)
connected = True
while connected:
msg_length = conn.recv(HEADER).decode(FORMAT)#how many bytes you can recive and also decodes the message
if msg_length:
msg_length = int(msg_length)#convert length of message into integer
msg = conn.recv(msg_length).decode(FORMAT)
if msg == DISCONNECT_MESSAGE:
print(f'[{username}] has left')
connected = False
print(f"[{username}] {msg}")
messg = f"[{username}] {msg}"
messages.append(messg)
if messages != []:
conn.send('message recived'.encode(FORMAT))
#messages.pop(messages.index(0))
conn.close()
def start():
server.listen() #listening for new connections
print(f"[LISTENING] Server is listening on {SERVER}")#what ip adress its running on
while True:
conn, addr = server.accept() #stores connection and address when someone joins server
thread = threading.Thread(target=handle_client, args=(conn, addr))#passing the arguments for the handle client function
thread.start()
print(f'[ACTIVE CONNECTIONS] {threading.activeCount() - 1}')#prints how many people are connected to server
print('[STARTING] server is starting...')#output to say server is started
start()#calling the start function
in the "msg_length = conn.recv(HEADER).decode(FORMAT)"
it gives me this error
"bad file discriptor"
Thanks in advance!
Can your ISP a see what you search on google since is HTTPS
I mean when you search something the URL contains what you searched
yes of course,
Generally, no they cannot.
If you use any sort of HTTP/S proxy, the proxy provider can likely see the contents of your URL. So unless you're using an HTTP/S proxy from your ISP, then not they should no be able to see the contents of your URL if you are using HTTPS.
Well... that on the other hand is debatable lol
Lol, I don’t have web activity turned on so in theory it shouldn’t save where I go
iN tHeOrY
Google does tracking under the hood and I don't know much about what they share with third parties. I just know HTTPS connections are safe and encrypted as long as you don't use a proxy.
I mean google is a private company and doesn’t stand to gain from reporting users to let’s say the police. Third party advertising sites on the other hand...
There's a lot of assumptions to be made there.
Wdym?
I don't speak for Google, but typically a company is more interested in protecting itself than single one off users. I can't say for sure if they actively report users to the authorities, but they'd probably be cooperative during an investigation would they come asking
Here's some info on how google handles these things https://support.google.com/transparencyreport/answer/9713961?hl=en#zippy=
Requests for User Information How does Google handle government requests for user information? A variety
Google is “88%” cooperative with authority investigations and requests
I read somewhere
But unless the police have a reason to ask for your browsing activity then google doesn’t tell them explicitly
Altho some keywords are monster like searches about kiddie porn and drugs and guns (terrorist stuff)
@prisma cobalt ISP can see the domain of the site you're requesting via DNS
so it can see that you're on "google.com", but not what you're searching
(unless you have dns over https)
how do i get the ip of the heroku server?
Hello Everyone anyone suggest a good resource on python for hackers.
How do I connect two different computers?
may be wrong here but if i search "hello world" on google then "=hello+world" appears in the URL. Does the ISP see this or JUST google.com?
Pls guys help me out , i suck at networking
Also can I randomly choose any port in range 0 to 65535 (excluding those in 1000's)?
yes, but yeah as you said dont choose any below 1024, i would reccomend 8080 for user applications
Can you share the basic code for connecting two different computers
Any link or code
Actually I'm new to networking
https://realpython.com/python-sockets/
brilliant resource
to 
