#networks
1 messages · Page 30 of 1
If you need anymore help @shy island then ping me
definitely 😄
Have you got a server and client script finished?
yes
Nice, do you know how to find your public IP address?
Ah that won't help, for your public IP, literally Google "what's my IP"
Beware this IP changes every few weeks since I assume you have a dynamic IP address
then i need to modify my code every week as well?
Yeah you'd have to change the IP in the client script every few weeks, however there is a solution
Follow the link at the bottom of the port forwarding pin to find it
yep i opened
also my actual task is that i have my ping pong game developed with pygame and i wanted to make it multiplayer , through a socket connection with 2 pc worldwide @prisma cobalt so all i want is to send the coordinates of the player and ball across the clients
Yeah that's possible with sockets
Website?
i mean ur pinned link xd
Ah right lmao
Hello does anyone know how to work with rak-net in Python?
I need help getting started with it
hey guys..i actaully have a client server python program to let client download from server..everythings fine but may i know how to list the directory of the server in client..like what files are in the server folder..PS...i have two pcs , one is server one is client..Thanks
using the os module your can scandir and send the results back
os.listdir()
Guys can anyone pls explain me what is th difference between socket and socket server module
Which would be efficient ? And which should i use
Thanks in Advance
do u mean socket.socket and socket.create_server?
no theres a import socketserver module (might not be that exact name)
no it is that
socketserver module uses the socket library but makes it easier
again this really depends on what you're trying to do 
true
lmao
Dont know if its the right categorie, i need help
i have a server connected through ssh
but i dont know how create open and edit a python file
its running debian 10 and ive already installed everything needed
nano is an easy to use text editor. You can use it to edit over ssh. Another option is vim. Pretty steep learning curve, and a lot or little configuring and plugging to do, but it can serve as an editor. Or use an editor on your desktop that can do ssh \o/
i have a ONOS SDN controller
how can i write a script to monitor the traffic on it ?
Hey guys I need help with my socket program
This is the description: Your job is to create the special-purpose web server to provide the backend to this functionality. Due to
corporate requirements, you must use the socket interface, and cannot use any module implementing a web
server directly. The program will answer various web queries and return a result. Below is an example.
Example: With the web server running, enter in the following formula into any cell in Excel 2013 (or Excel
2016):
=WEBSERVICE(“http://localhost:1234/zip/98101)
Excel should then show a result of:
Seattle, WA
Listen guys i just wanna recv full data in tcp so i thought maybe socketserver module does that auto
In tcp after 1024 bytes it will break your data but i dont want it
I want a efficient version of socket (server side)
Anyone?
The 1024 bytes limit is for 1024 bits at a time
So you can keep sending and receiving data in a while true loop till theres no data to send
Yeah exactly i did
Noice
But in some times it appends next data with old sent data
Text data but still if i send 2 data one after one new data appends to old data
Which i dont want
Hmm
I dont quiet get your issue
I mean, i get it, but it kinda doesnt make sense
Text data is supposed to be sent 1024 bytes at a time, you get a buffered input from the input() function, you kepp sending the input text data 1024 bytes at a time
The next input happens, the received data on the server side will be appended after the previously received data
Suppose i send like this
So.send(1)
So.send(2)
In recving data "2" appends with "1" so full data is now "12"
Ooh
Where are you storing the received data on the server side?
In a variable?
I believe you're updating the variable as
*that variable += received data"
If that is so, its gonna do the previously received data "2" + "1" = "12"
Ig it makes sense lol
Lol i save in variable but i want a fix
I only and only want to get data of packet which sent
Not the next one in old one
@trim moth
Oh
Use a datastructure like list
Just append the received data in a list every time you receive something instead of storing and updating in a variable
@latent socket How does that sound?
but it is same thing in a different way next data will also append to that list
Oh, so you want to get rid of the old packet after receiving a new one
Thats why you were using variables in the firat place ig
Then, just dont update the value of the variable you using, instead just redefine the variable as in
X = old packet data
Then redifine it as
X = new packet data
I wanna get rid of new packet in old one
get rid of new packet in old one?
Yez as i gave example
.
Can you show your code
I still think redifing a variable instead of updating it would help
It'd be easier to help if i understand what you're doing
Hmm i will show you
Yeah, sure
@trim moth
here we go
def send_text(data,conn):
data+="¥"
conn.sendall(data.encode("utf-8"))
def recv_text(conn):
buffer = ""
while True:
data = conn.recv(1024)
data = data.decode("utf-8")
if data.find("¥") != -1:
data = data[:len(data) - 1]
buffer += data
break
buffer += data
time.sleep(1)
return buffer
Try buffer = data
Instead of buffer += data
Hit me up if it works or not lol
You should use the chr(255) instead of "¥" to improve readability
Yeah, but it didn't matter much to me lol
@modest pebble bruh we got complementary color schemes going on lol
it wont give me full data
i want a full data
You mean, you want all the data you have entered to be printed right?
no i want all data in one single string
so i can do something
by getting half half data its useless
Like in that example, you want "1" + "2" = "12" to be your output
In that case,
def send_text(data,conn):
data+="¥"
conn.sendall(data.encode("utf-8"))
data_list = []
def recv_text(conn):
buffer = ""
while True:
data = conn.recv(1024)
data = data.decode("utf-8")
if data.find("¥") != -1:
data = data[:len(data) - 1]
data_list.append(data)
break
data_list.append(data)
time.sleep(1)
return ''.join(data_list)
Trai dat
🥲
-_- you didnt understood this is my problem
But that gives you your data in one single string lol
i dont want last sent byte to append in first byte
Oooh i get it now
and what he was saying to use chr(255) instead of that ¥ symbol
which charecter is 255 ?
Idk lmao, its same anyways you use chr(255) or that character lol
🤦♂️
def send_text(data,conn):
data+="¥"
conn.sendall(data.encode("utf-8"))
def recv_text(conn):
buffer = ""
while True:
data = conn.recv(1024)
data = data.decode("utf-8")
if data.find("¥") != -1:
data = data[:len(data) - 1]
buffer += ' ' + data
break
buffer += ' ' + data
time.sleep(1)
return buffer
Just added a space lol
lmao
reply to that guy
lol
i mean for logic less answer 🤦♂️
Dis code work?
😒 what space will do
lmao, what your desired output should look like?
wait dude let me show you
yeah 😁
see i sent 2 packets
in server side /Write Output will write data to a file
and /ADM will read a file and will send client data back
but see in data file what happened my packet /ADM also append to data file
while it should not be append because it is a different data and it has different work to do
Hmmmmm
😑
🥺 😑
Make it so that on receiving '/ADM' it will not append it to the file like it does everytime
lmao i dont have anything better to do
Noice
who needs help with what?
if what your asking is dynamically changing the size of how much data you recieve without it breaking than thats easy
hang on im just looking through what thyBro suggested
yeah so you need a set size message, lets say 64 bytes to begin with, you recieve these 64 bytes and it tells you the length of the incoming message so you can recieve exactly that size
you get me?
64 bytes is enough since its max is a number that can represent 18446744073709551616 bytes which is around 16 exabytes
ok il give an example
MessageSize = Sock.recv(64).decode()
Message = Sock.recv(MessageSize)

you sure with multiple clients any request can come at any second you can handle recving 2 times
this is my current PROGRAM
your reading the file wrong i think and are you using the native socket lib since send_text isnt a function i dont think
.
its just reading my task manager programs list
os.popen is a method to use batch commands
by using tasklist you can get taskmanager programs list
ah right
yeah you should probably do my method
aka: sending the message size AND THEN the message
what is the efficient method
alternatively you could send one message of X size with the total message length in the designated bits in the front, then your program knows to keep recving data until its reached that number in the designated bits
the problem is if i sent a 2nd message in that time it also counts that in first message recving
i think thats cause your += the data
i have no idea its up to you
first solution is probably sends 2 pieces of data per transfer
the second only one
😒 noice
@latent socket
@prisma cobalt
If the received data is "/ADM" , DON'T APPEND (i.e. dont do buffer += data)
Instead, do whatever you want to do with it.
Else (i.e. received data is not "/ADM") put it in the file
That's based on what yiu told me about "/ADM" has a different function so that "/ADM" wont be appended
How does that sound
For real? Or u kidding
?
lmao i wonder if that could be the solution lol
hi i need help with requests
Just ask your question :)
for example website doesn't loading fully https://www.footlocker.sg/en/all/new/
What do you mean?
Yeah
lmao this made my day
You are very active and friendly☺️ ☺️
does anyone know how to make a remote desktop gui?
i saw you typing
píng me if anyone got a anser, please
I have a very simple system, now this uses time trigger so every 2s a data is sent to the other system. Is there some sort of default/ best interval for this type of system ? I was thinking maybe 4s is good enough because the temp of the sensor doesnt change much so it is kinda pointless to send data every 2s. This is the first question. For my second question what If I used a mix of event and time trigger. Lets say 500 is low and 550 is high. I can have it so it will start sending data every 2s when the value of the sensor is at 550 only. Is it better to use only time/event trigger or a mix system ?
id say its better to use an event trigger system, simply because it reduces network traffic since it only updates when it needs to. However it would be good to maybe send the current time every x hours just to confirm the connection and the mchine is working fine
@prisma cobalt can you provide a more in depth answer or a paper where I can read more about why it should be trigger system in this case because from what I found it usually mixed system works it has the trigger part but also the time part ofc it introduces its own drawbacks, or maybe I am completely wrong and dont know what I am talking about. Lets say I use a trigger system when the temp is over 550 and stays wont it trigger the event over and over again because it meets the condition, and yes timed trigger sends data based on the interval that was chosen, but the system is ready for that because it is expecting some sort of data. Again maybe I am completely wrong on this, if anyone else want to correct me feel free I am trying to learn anyway
Remote Desktop GUI?
I suppose it can be done with tkinter, but the actual GUI is opened through a command sent over network connection
I can’t sorry, I’ve never thought about a problem like yours before
what is base64??????????????
It allows to code binary data into text representation
hi, i need to make a chat in django, can some one help me?
?
@bitter agate i dont have much experience in django, but i can help set up a chat app using sockets if thats what you want
yes that would be great
can anyone help me how can i make a free server??
aws or heroku or something silimlar
ok
what its used for?
is that how should i do it?
nvm i screwed it up.... forgot to use sys
Hey this will be a javascript question
Why am i getting undefined in console log?
Hello 🙂 This is a Python server, so Javascript is considered off-topic here, I'm afraid. But feel free to ask about this in one of the off-topic channels.
!ot
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
Is it possible to connect two clients with voice chat using socket?
yeah
Intresting, imma go look into that lmao
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
print(s)
def netWuff(sock:socket.SOCK_STREAM):
res = sock.recv(2048).decode('raw_unicode_escape')
print(res)
sock.send(b'1\n')
ret_str = b''
res = sock.recv(8192)
while res:
ret_str+=res
res = sock.recv(8192)
sock.close()
return ret_str
This while loop aint working lol, i wanted something that just keeps receiving until stream is empty -.-
Is there a way in py to make that work?
How about flag MSG_WAITALL? https://manpages.debian.org/buster/manpages-dev/recv.2.en.html
!d socket.socket.recv
socket.recv(bufsize[, flags])```
Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by *bufsize*. See the Unix manual page *[recv(2)](https://manpages.debian.org/recv(2))* for the meaning of the optional argument *flags*; it defaults to zero.
Note
For best match with hardware and network realities, the value of *bufsize* should be a relatively small power of 2, for example, 4096.
Changed in version 3.5: If the system call is interrupted and the signal handler does not raise an exception, the method now retries the system call instead of raising an [`InterruptedError`](https://docs.python.org/3/library/exceptions.html#InterruptedError "InterruptedError") exception (see [**PEP 475**](https://www.python.org/dev/peps/pep-0475) for the rationale).
can anyone help me how can i make a free cloud gaming server
you just gotta have a host machine to actually run the game and then send the player inputs from the client side to the host server and somehow make it so that the received player inputs are given in the game running on the host server. and while all that is going on, the video of the game running needs to be streamed on the client device. the sending inputs and streaming part can be taken care of by sockets since there's a way to stream video over sockets too, the part i don't have much idea bout is of giving the received inputs to the actual game. but there are limitations like lot of lag, not sure bout the video quality or frame rate of streaming and stuff
dayum i finished a whole bowl of chips just typing that
can anyone help me to make a cloud gaming server??
ThyBro told you how?
@ember ledge I'm not friending you, talk here on the server
tell me how to make a server
You need to first receive player input
There's a basic socket server code in the pins of this channel
tell me how to do
@prisma cobalt
Go to the pins of this discord channel and look at the 2nd one
Thats a basic server
so what i will do next
Now you've found the code, learn python socketing with that as an example
There are resources on that pin
@ember ledge try googling about how people set up minecraft servers
i want my own server
not mineraft server
ik
all that differs in your idea is the game you want to run pretty much all the other things remain the same
File server? Game server? Email server?
game server
In python? Good luck mate
what do you mean by a "game server"?
you are developing a game, and you want it to be a multiplayer one with a server?
yes
i want to upload that game in my server
@inland rampart
Upload? So it's not a game you're developing? how is that Python-related though?
i donot know
i am facing issue so i am asking
Wait, are you or are you not making your own game?

i am making my own game so i want to make online
so for that i want a server

so how to make a server for free
Okay you could make a script in python to handle clients
Your gonna have to host it yourself or get very limited connections/options
please can you give me a video so i an makec


where i will use
and how to make
What? You need to learn socketing first, I've given the you the resources to do that (realpython tutorial link in the pin I mentioned earlier) and there's an example of a client server program
Learn python sockets first if your doing it in python
Which I assume you are since your asking here
ok
after by using that where i will run
and what output it will give
and where to run
Run it using python, the output is whatever you print, run it where you want
I'm getting the feeling that
A) you don't know python at all
B) your not listening to me when I say learn python sockets and instead your using the code without knowing what it does
bro i have my own team of game developing i have artist and animators coders and all website devlopers
so i am the owner so i cannot make a server so i am taking help from you
As the owner will you be writing the code?
If not then anything I tell you here is pointless
no other person is there
i am the story maker
and scripting
What's the point of me telling you then, on this python server, how to set up a socket server that handles multiple clients if you don't know python and aren't interested in learning?
bro error is coming during running in vs code
getaddrinfo failed these error is coming
I thought you weren't coding?
i am a coder but i use html and css and flask all these for website development
So not python?
i am learning python
but website development i know all parts
he knows
That's great but not very helpful in this situation
But python?
Okay so if he's know python and he's the coder then he should be asking not you lol
He's the one implementing the server scripts
He's the one doing the code
he is not incharge of making a server
so he is busy in coding
he cannot make a server
so i have to make
tell how to run
i suggesting completely neglecting python here

Python is quick and easy but for a full game will be hard to use
he's not a bit interested in python and just wants a way to get his game on a server
yes
Are you hosting yourself?
to the point answer
lmao
yes i want to host my game in that server
No no no, sure your hosting your game but the machine that your hosting on. Is it yours?
and is it a server or your PC you're hosting on
Like do you physically own it?
yes i have my own pc
so i want to host there
noice
ryzen 5 4600h,8gb ram.512 gb ssd,gtx 1660 ti 6gb graphics dedicated and 3 gb radeon graphics intergrated
The game won't be run in the server, that's the clients job, all the server does is manage connections and sending data between points counting data about each client
only 2 weeks old laptop
wow
so tell what i have to make
and do for that
What type of game is it?
look, dude, the connections your game accepts and the data it sends to the clients is supposed to be completely in the game code, so make your programmer take care of that
it is a storytype game
as of running it on a server, it's just to provide the ip and the port for the clients to connect
so how to make that tell me
The clients send data
This could be keyboard input
This could be world positions
This could be a JSON object
The server receives this data
And it send it each client connected, then the clients use this data to update their own screens, reflecting what has happened
This is a job for your coder
the code and the mechanics of the way the game interacts with the host machine to manage client connection is dependant on the networking code your programmer writes
so what i have to do to make the server
FFS listen to us instead of spamming the same question :(
after the game ready can you host the game on the server
just don't make the server, make the game in such a way that it makes the machine it's being run on, the server
nooo nooo
shit i messed up
anyways, gotta go for dinner lol byeee
To make the server you need CODE, you've said your not doing the code but your coder is
We are not gonna just write it for you, your coder needs to do his networking research. He needs to accept connections and manage them
That's all there is
on point my man
if i giev you all my game codes can you make the server for me
why would i do that for you? besides i dont know C# very well which is what your coder is using with unity.
ok
this is a job for your coder to implement @ember ledge you cant do any more
my coder cannot do
and i also cannot do
and bear in mind that this task is a huge one, its not easy implementing networking
cant he learn how?
no he cannot
well then your stuck, unless you pay someone to do it for you which will be expensive
ok
try hiring someone else lmao
ok
Hello guys, I want to ask if there is any module in python which requests a url, and download all the content including images, not only html.
From what I know requests module only saves the html content
Selenium can do something like that (it's pretty much an entire browser you control from Python).
You can also just, well, also grab all the links on the page, but that won't help with content that gets loaded up using JS, and selenium would.
hello networking people
ello
Is there a scapy discord?
sock.recv(4096) gives me BlockingIOError: [WinError 10035] A non-blocking socket operation could not be completed immediately when using nonblocking connection, so how to do recv from such object?
bruh
i found out that kahoot stole a loop from garageband doe
hi does anyone know how to make a client-client interaction via a server ofc
Hey @ember ledge!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
fuck you
lol
be nice to the bot 😦
lol
Get ready to embark on the journey of a lifetime. Help out your favourite Money Heist characters and get better at competitive coding while you're at it.
Register now and pledge your allegiance to the Dali mask!
The Professor's counting on you.
Registration link: https://register.dscsrm.com/
Register for the code heist!
Please shhh, this is networking channel not somewhere to advertise whatever bullshit that is 🙂
Any of yous have any idea why my (first) Flask app isn't showing up on anouther computer within the same local (VPN) network?
no idea how to use flask but those ip's on the left mean "localhost", they are local ips and another system connecting to that ip would just cause them to connect to themselves
Yes, I'm trying to connect externally to the IPv4:5000
@desert ridge server is windows / linux, and what is client?
goodday, looking for recommendations on books/online resources on sockets
or is man pages as good as it gets
import requests
from requests.structures import CaseInsensitiveDict
url = "https://discord.com/api/v8/users/@me/settings"
headers = CaseInsensitiveDict()
header_names = ["authority", "method", "path", "scheme", "accept", "accept_encoding", "accept-language", "authorization", "content-length", "content-type", "cookie", "origin", "referer", "sec-fetch-dest", "sec-fetch-mode", "sec-fetch-site", "user-agent", "x-super-properties"]
header_content = ["discord.com", "PATCH", "/api/v8/users/@me/settings", "https", "*/*", "gzip, deflate, br", "en-GB", "TOKEN", "79", "application/json", "__cfduid=dd3da19ce3fd060f9f486ff27f55606ff1618892516; __dcfduid=df64a4be6c464b739ed58af8bd429b25; locale=en-GB", "https://discord.com", "https://discord.com/channels/@me/775841711812902922", "empty", "cors", "same-origin", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9001 Chrome/83.0.4103.122 Electron/9.3.5 Safari/537.36", "eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiRGlzY29yZCBDbGllbnQiLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfdmVyc2lvbiI6IjEuMC45MDAxIiwib3NfdmVyc2lvbiI6IjEwLjAuMTkwNDIiLCJvc19hcmNoIjoieDY0Iiwic3lzdGVtX2xvY2FsZSI6InB0LUJSIiwiY2xpZW50X2J1aWxkX251bWJlciI6ODI3NTAsImNsaWVudF9ldmVudF9zb3VyY2UiOm51bGx9"]
print(len(header_names))
print(len(header_content))
for i in range(0, len(header_names)):
print(header_names[i] + " is " + header_content[i])
header_names[i] = header_content[i]
data = """
{"custom_status":{"text":"diggytest6","expires_at":"2021-04-22T03:00:00.000Z"}}
"""
resp = requests.patch(url, headers=headers, data=data.encode("utf-8"))
print("\nRESPONSE: " + str(resp.status_code))
Why does this return "Unauthorized" ?
note: i put my token in place of "TOKEN"
sorry i don't know if this is the right channel to post
Any idea if it's possible to use Streams in a Client of the HTTPX library?
Not sure if it actually has anything to do with this channel
false alarm* my bad
my bad 😬
but thanks for being a bro
sorry for sounding rude, i didn't mean to, i only realized it now, thank you for worrying
You didn't sound rude at all, no worries.
hi does anyone know how to make a client-client interaction via a server ofc
With localhost only the machine that you are hosting can connect to the server
To host to the VPN you need discover what is your pc IP in the VPN
So you host your app in this IP
both client and server are unfortunately Windows
I was trying externally connect to the IPv4
.
localhost its only your machine
you cant host on localhost and access trough other devices
doesn't me broadcasting the app on 0.0.0.0 make it visble externally I thought?
I've also tried broadcasting on the actual IPv4 of my machine. Is there anything I've missed?
@desert ridge with flask running, can you try to telnet <windows_ip> <fask-port-number> # from the client
Appologies for the delay, VPN issues.
It's saying that telnet isn't reconised... is it a program I need to download/install?
Apparently I can't install telnet:
nope, broadcasting on 0.0.0.0 or 127.0.0.1 or localhost makes its only visible to the self machine
You need host on 172.20.2.101
to make visible to other devices
python socket servers use 0.0.0.0 to allow incoming connections from anywhere, be it local devices or external
127.0.0.1 is localhost only like you said
so i can access from my phone that is in the same wifi that the host machine only typing 0.0.0.0 ?
and, being in japan, i can access from my phone the host that is in the US only typing 0.0.0.0?
well your public ip factors into it
exactly
socket.bind((0.0.0.0, port)) "bind" with "0.0.0.0" allows incoming connections
How can I create a ftp server with host url/address?
So I can give the host address and credentials to someone, so they can upload files to it
And the other person doesnt have to be on the same internet as us
is this a good place to look for a help with communicating via bluetooth?
hi
just give us a try lmao
ello
hey i have a question, im trying to pass an image from me client to the server.
i wrote the function:
def send_image(received_socket, file):
print('Sending...')
byt = file.read(1024)
while byt:
print('Sending...')
received_socket.send(byt)
byt = file.read(1024)
file.close()
print("Done Sending")
received_socket.shutdown(socket.SHUT_WR)
now this works fine, apart from the last line. without it sending an image doesn't work. with it i can't send other messages after the image which is very necessary for a chat app
if anyone got a fix/workaround it'll be much appreciated
try socket.close()?
i dont want to close the socket
oh
i want my chat app to keep working after the image is sent
calling socket.shutdown() indicates that the caller (the client or the server) has no more data to send and the socket is basically closed
so just dont't call it
and continue with you chatting code
lol
without it sending an image doesn't work
not only the servers stays in an infinite loop
but the image it gets is corrupted, cant be opened
whoa
is that in the same messaging loop as the messages?
coz once a file is transfered to the receiver 1024 bytes at a time and written to drive, it does'nt matter what happens with the sockets or the image (since the image is received and written on the receiver's side) right?
and if the code continues into the message sending/receiving loop after sending the image, i dont see how it'd enter a infinite loop
i found this code online. the explanation behind shutting down the socket is
Client need to notify that it finished sending, using socket.shutdown (not socket.close which close both reading/writing part of the socket):
so without it the server is going to keep trying to recv an image, getting stuck in an infinite loop. and when i do shut it down i cant continue to use it...
the output also is very weird
file = open(f'data/image#{3}.png', 'wb')
print("Receiving...")
byt = sender_socket.recv(1024)
while byt:
print("Receiving...")
file.write(byt)
byt = sender_socket.recv(1024)
file.close()
print("Done Receiving")
and the output is:
Receiving...
Receiving...
Receiving...
Receiving...
Receiving...
Receiving...
Receiving...
Receiving...
it doesnt get stuck inside the while loop but it never leaves it either? (this is without shutting down the socket)
so in the end of the image (i.e. when the image sending is done from the client side), send a string like "done" or something on receiving which the server would stop recv and image and avoid getting into the infinite loop
like the special keyword would tell the server to stop receiving/expecting and thus, the server should stop
like,
if received_data == "done_sending_image":
break
(or leave, or whatever)
else:
do whatever you want to do with the data
```or something similar if you get the idea
makes sense?
k ill try that out
huh
weird
even if im sending "done" it recieves nothing
i just changed the check slightly to check if it gets nothing, if it does break
and it works
wierd indeed
Hey @trim moth!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @trim moth!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
f u
Hey @trim moth!
It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
let it be
file = open(f'data/image#{3}.png', 'wb')
print("Receiving...")
byt = sender_socket.recv(1024)
while byt:
print("Receiving...")
file.write(byt)
byt = sender_socket.recv(1024)
byt = byt.encode()
if byt == 'done':
break
file.close()
print("Done Receiving")
lmao
Is there a manual equivalent of socket.gethostbyaddr? My issue is that when doing socket.getfqdn, I am unable to in any way time it out, and I dont want my program(s) to get stuck checking an fqdn for 14 seconds (which is the highest ive been getting w/ my dataset).
Please @ when responding.
@lost hatch just start a timer lmao and if it exceeds 14 seconds, call exit()
or close the socket
socket.getfqdn utilizes socket.gethostbyaddr, so I cant manually close the socket, unless I find out a manual way to do socket.gethostbyaddr where I have that type of control.
import socket
HOST, PORT = '', 8000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
s.listen()
index = open('index.html', 'rb')
while True:
slave, addr = s.accept()
slave.sendfile(index, 0)
print(f'[*] {slave} : {addr}')
data = slave.recv(8192)
print('[*]', data.decode(), '[*]')
What am I missing? Wanted do the simplest http server using sockets
ERR_INVALID_HTTP_RESPONSE
are you getting that error when u run it? It's running fine here
Ummm end of transition was supposed to be signified by empty send (0bytes). Alternative is to have it prefixed with size or to make some kind of protocol over TCP or use existing one. Why while loop is there well yeah TCP is stream but one still gets it like a message it might be split or merged by stuff on the way but still it's bit tricky as it would change latency. So it depends on the network devices, APIs and implementation of those. In raw protocol one expect the message to be slit into packets and potentially fragmented when it's being sent through network. TCP is still over that so it guarantees a sequence and retransmission (to a point) so you get stream of data and shouldn't depend too much on the actual size and number of messages.
That being said it's highly pathological to get messages of few bytes. But it may happen just usually it means that user sends small chunks and forced small send window or forced merges off. Plus TCP reorders stuff and if it's for latency well it might not be the best protocol for such short messages or might be okay.
Umm your missing the http protocol part which at http 1.0 is pretty much prefix before the data.
https://en.m.wikipedia.org/wiki/HTTP_message_body.
IE minimally STH like:
HTTP/1.0 200 OK\r\n\r\n
Content-type might be nice thing to have for a client to know that the heck it had to do with it
Ummm frankly it's been pita and one may do that on separate thread and ignore the results but I don't know if it's solved or not in some compatible ways.
Hey @balmy ember!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Ummmm direct connection is required so yeah host has to have some port available unless you want to put FTP over something like VPN with third-party maybe with umm no idea if it's still popular back in days I used hamashi and if worked. But the first part about writing FTP server well I didn't bothered to check what is the minimal set of commands to support to be useful but something like get or put seems to be minimal. Question remains whether some client will live with that or yap about missing ls and other stuff
Will see if I'm helpful here hehe
I'm not so much into network programming as in basics but why not you will just smack me if I say nonsense.
Does anyone use UDP socket?
they have a variaty of use cases
tcp is more common tho i think
since its lossess to an extent
Please try to be more refined in questions. Like anyone here ? Or anyone in umm some scope ? Or are you inquiring someone for help. Hehe 😊
Generally for the use it's almost raw IP frame so well you have more control over pockets and more responsibility as well. Stuff gets nasty here, but you get finer control if latency is killing you
Plus multicast and stuff like that
ooooh sounds noice, only done tcp stuff till now tho
Is it like most things that can be done using tcp can be done using udp too?
rather its must be just a choice if yiu want to use tcp or udp
i get the error
on socket.io.js:1
pls help
share code?
What are the headers set in CORS and how do their values affect things?
They only apply to browsers really
They control how the browser can interact with responses from a server
E.g. The methods its allowed to read data from, headers allowed etc...
i was trying to make a script that will download and run another script but using the requests library i cant figure out how to get the data from the .py file?
Hi, im trying to make a simple get request to this website however i keep getting a 403 error.
I used postman to get the headers.
url = "https://www.games-workshop.com/en-GB/Home"
headers = {
'cache-control': "no-cache",
'postman-token': "e7e7af22-60e4-8aed-f0df-9084abfe4a2d",
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36'
}
response = requests.request("GET", url, headers=headers)
print(response.status_code)
Any reason why this is happening. I also tried copying all headers from the network tab and nothing happened.
once you have it, isnt it just an open() read()?
i got it to work now it was a server side issue on the server hosting the file
👍
does anyone know how to operate ec2 instances?
i'm trying to run a flask app on one but it's not connecting through HTTP
I'm gonna go to sleep now, but leaving this here overnight:
How could I go about making a web dashboard so my bot can be controlled from there?
Please ping me if you can help, hope this doesn't break any rules lol
something like flask ?
a 403 error means forbidden
are you allowed to access the resource?
The HTTP 403 is a HTTP status code meaning access to the requested resource is forbidden. The server understood the request, but will not fulfill it.
Yeah its just a website
hm
it looks like the request is being understood but you're just not allowed access, maybe it knows it's a request via python?
have you tried without the headers?
hm yea good luck with it 😦
Can someone recommend a great solution to hosting a FastAPI on multiple servers so the load can be balanced and if one goes down the other can still handle the requests?
nginx , HAProxy ?
Or, the native loadbalancer your cloud provider is offering
Ummmm certificate any by perhaps ? Check with some network sniffer like wireshark on what is being sent during ssl handshake
How to get an OAuth2 authorised session in aiohttp?
Hi, I am running an async TCP server to control a few switches remotely. When I send a command to a switch, the switch sends back an acknowledgement message.
The issue is that I can't tell which device is sending the acknowledgement message when I send multiple commands.
I tried using the transport object and peername tuple but the issue the devices are under a NAT so that info doesn't help. What attribute in the socket can I use to figure out which device is sending the acknowledgement?
That won't work. Each device has multiple switches. If I turn ON switch number 1 for all the devices then I will get the same acknowledgement message from all. And the device is a black box. I can't change its firmware :/
When I send a message using the device's transport object that is stored in a dict then the right device receives it but I am unable to identify the device when it sends the acknowledgement message. Is there something I can use in the transport object?
I think cloudflare is blocking the request
anyone know a python curl library because PYcURL is python 3.8 and i have python 3.9
that worked
now just to figure out how to parse xml -> python class structure
(if this is wrong channel point me to the right one)
because curling the api gets this
<NATION id="walksanator">\n<NEXTISSUETIME>1619502040</NEXTISSUETIME>\n</NATION>\n
i hope it parses right
wait
how do i get the nation
because i dont think you can acess a member of a class via a variable
re-phrasing
how do i acess a element in a python class by a string variable
getattr
udp proxy server
I want to create a proxy server.
But it hasn't been realized yet.
who can help me?
- Quickly modify the data package.
- Port multiplexing.
#web-development message (cross channel posting because it may fit here but i dont want to spam the information which was allready posted)
does socket have a readexactly method? i want to receive a specific amount of bytes, and the size is given by the header
mmm not really because it's fairly low level
it'd just be a while loop though reading until the amount is satisfied
Ummm it's somewhat possible to a quite small sizes if you have control over TCP or over UDP. But normaly you write something that can tell where the message starts and ends within virtually infinite stream - that's the approach over TCP
hmm well the maximum amount of bytes is going to be around 12k
It's too big
yeah..
thats why i needed a proper method
buff = b""
while n > 0:
b = self.client.recv(n)
buff += b
n -= len(b)
return json.loads(buff.decode())``` i dont think this is gonna work properly
alright
@gloomy root as well, you can recieve an exact amount of bytes with: socket.recv(number_of_bytes)
that depends on your configuration but yes it can
that could receive lower bytes than that sometimes right?
though IIRC it's not garenteed
it reads upto that amount
but you dont get that amount garenteed
yeah my bad, shouldve said that as well lol
how do i make headers again 🤔 like how would i get n
but @clear rock if you send a set sized message (header) (say 16 bytes) only containing the size of the next message you can recv exactly that size
so you recv the header first which is 16 bytes (always will be) then decode it and find the size of the following message
you get me?
hmm yes
so i need to send 2 times, one for the payload and one for the header?
i check if it is 16 bytes and assign that value to n
It's just a stream so might be one send but you need to make the message somehow so either in buffer or by send
oh, so BytesIO?
thats one option, on the other hand you could have a set message size (say 1024 bytes for example) and if the message your trying to send is longer then that then you split it up and send multiple messages containing the original message
What are you actually trying to achieve here
well
it's sorta sounding like you want a HTTP server rather than raw sockets like this
i am making a simple multiplayer board game, and it works for windows clients, but i dont know why but linux client gets about 1400 bytes from the 12k
You should probably use a higher level system for this
ooo cross platform, interesting
if its just a board game HTTP is probably the easiest and most reliable
eh they could but sockets still work
oh
altho it would be easier yeah probably
sure, but you're gonna end up doing HTTP style anyway
so websockets?
Like data flow and data management with sockets is a masiveeeee pain in the ass
websockets would work yeah
😂 yeah
have one player essentially be the host, others be the client
thats fine too
oh okay, i think sockets is more suited for P2P
theres some confusion i think, i gather vinam wants to use an external server instead of a player server
not at all
cause my program works on localhost and local network fine
I think you might miss understand what P2P means

everything network based is built around sockets
P2P is client to Client with no server intermediate
okay im gonna give you a solution Vinam, give me a sec
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
before i start i assume you have an external server your running yourself?
yes, on a vps
yep okay
Depends what you want to do. For plain stream of message over some kind of protocol over TCP separated from app is not so bad. Dynamic languages are easy to write state machines or else nice switch case ladder of doom XD
this is how to circumvent port forwarding as well (for the clients, not your server):
i was actually doing this in rust tcp but yeah i gave up midway and switched to python 
You'd end up with about 500+ lines of code to make a proper socket system like that
speaking from experience
welp
it takes alot of data management with raw sockets
HTTP and websockets is by far the simplest and easiest method
- make each client connect to the server you have running
- any data the server recvs, broadcast it to all other connections
if your using sockets:
have a set message size (x bytes)
keep recv/sending untill the message has been completely sent or recved
oh, ill go try out http.. gotta learn it first
i dont think messages for a boardgame will be that big
okay man, your choice
uh well its battleship
so messages are just 6 bytes
but
lmao
just have the server echo the client message to the others
Yeah so not much data
If you already know the size of the message then why are you worrying?
I would use sockets in that case
9 TCP/IP packets is not end of the word.
hmmmmm
i wouldnt even be worrying if i didnt get incomplete packets in a linux client
, idk the reason but i want to know how it works for windows
It's assuming that 1420 (40 bytes for extra Linux headers) so TCP/IPv4 over Ethernet by default.
So yeah TCP over Ethernet slices stream at 1500 bytes minus protocols headers (IP and TCP)
oh
but shouldnt socket.recv ensure that every packet is reached and then return the data?
You seem very knowledgeable @tough dagger lol
or does it return each packet 
Returns each packet
oh damn
You can get sendall and you can implement your own recvall tho
that explains it i guess
i am just receiving once
thinking .recv gonna give me full data 🥴
it worked on localhost so it never occured to me 
Lmao
Localhost is not network really
yeah...
It's a loopback device
It might go to driver and back so has some latency but not real one
so how do i send a header or something like that
so that i know how much to receive
and loop till i get that much
You already know the size of your data packet tho?
Send something small first or fit message in some buffer after header and then send
it can be 12k or 6
12k in the start, 6 when the game is running
wait, so like the first packet should be the header
and it should be small enough to fit in a packet
It will be chunked and sent, then it might be chunked on network device so you will get it in those (well in theory second end could merge it at random but it may affect latency). So on client you read what you have untill you read umm header and then you know the rest
oh
so your saying surround the message in the header so you know when to recv and stop?
For the basics yeah
👍
It's what http actually do
Add feaking few lines separated with CR LF with message status, headers, and later on data, sometimes in header there's size
End is signified by read of zero size as the connection closes (logically or actually)
it either gives you a Content-Length or Transfer-Encoding: chunked or None in which case the default is 0
no? wait what is that question, maybe im being dumb
This sorta goes back to the whole HTTP thing i suggested
idk how to send a header 
headers are just a virtual thing, not a direct TCP thing
Ummm you may by then it kind of beats the idea of fixed size item 😂
you cant/shouldnt put them in your JSON because you dont know if your JSON will be valid or not without reading all the data and at that point you dont need them
yeah..
HTTP looking pretty 👌 rn
lol, didnt think i was going crazy
how would that work? a mixture of GET and POST requests?
im new to this side of networking
well no just use HTTP and WS
ah i dont know really how that works lol, something to research i guess
im more of a traditional socket person
you basically start with a HTTP request and it gets upgraded to WS via a upgrade call
whats WS?
websocket
Web socket is just a socket and bootstrap of http
ahh
Like mentioned
so its like normal sockets but in a special format?
well its bidirectional messaging for the web essentially
the advantage being that other people have already done the hard work of the body checking, size management etc...
so all you gotta do at the end of the data is just echo the messages your server is given to clients rather than directly checking it every time yourself
keeps stuff simple 😉
Thx
has a great demonstration and break down
thx man
def receive(self, size=default_buffer_size):
buff = b""
n = int.from_bytes(self.client.recv(8)[:4], "big")
while n > 0:
b = self.client.recv(n)
buff += b
n -= len(b)
return json.loads(buff.decode())
def send(self, *data):
if len(data) == 1:
data = data[0]
final_data = b""
final_data += len(data).to_bytes(4, "big")
final_data += json.dumps(data).encode()
self.client.send(final_data)
``` i still want to try work it out in tcp >.< this doesnt work though, json.loads(buff.decode()) here buff.decode seems to be returning nothing
hmm well i am getting this in server
oh wait
it is supposed to be len(str(data))
or len(json.dumps(data))
It's bit more tricky with dynamically sized first message you need to parse the end first and buffer it on the way if you're so into JSON but darn simple HTTP + JSON would make it so much easier you would get message not a stream.
Not saying against as hell play all hell loose why not. But pure TCP is basically like previously mentioned designed as a raw steam
The is no end virtually
So parse JSON makes no sense untill you say that from here to there is a JSON
HTTP uses double CR LF sequence to find the end of its header and start of get body in response

Just think about the hustle you need to limit headers not to be a sucker the allows one byte transfers just to get server out of open ports XD
And maximum delayed time of byte transmission
Then you need to limit not just max header size but also possibly the rascalityness of a (ab)user and disconnected
Which is why I adviced for a prefix notation with a fixed size start at the very least, it's simpler that way
Damn dude you're as stubborn as hell hahaha it's actually easier (to go with http) ..
Than what you do but stubbornness is a good quality if used right
Might as well sit till midnight till you get it working
Why the hell not if that is what you want to spent time on
oh actually
i change my mind
the header thingy works for the data server sends in the start
but now the game doesnt work
like the small communication of 6 bytes aint working

oh i forgot to restart server it works now
done now time to check on vps
hi i have a question in socket i need to add my locale ip and port but how to do this in host like repl?
No idea 🤔😺
Guys ?! Panic mode 🤣
i dont think REPL allows connections...
they cant assign an ip to every REPL since there are thousands

can i see your code @clear rock
sure, ```py
def receive(self, size=default_buffer_size):
buff = b""
n = int.from_bytes(self.client.recv(4)[:4], "big")
while n > 0:
b = self.client.recv(n)
buff += b
n -= len(b)
return json.loads(buff.decode())
def send(self, *data):
if len(data) == 1:
data = data[0]
final_data = b""
data = json.dumps(data)
final_data += len(data).to_bytes(4, "big")
final_data += data.encode()
self.client.send(final_data)```
thats the server?
so your using normal sockets instead of HTTP?
nice
Yup minimal working set and if it works well 😊 it's enough
I always prefer lower level stuff over higher level stuff
Makes it more interesting
Hi,
is there anyone familiar with ZeroMQ (async pyzmq)?
Nope but had some time with ∅MQ
And nanoMQ both from C++
No idea if it's enough for what you need but well might give it a try
Thanks, unfortunately I need some sleep. Maybe we can chat tomorrow...
data, addr = sock.recvfrom(1024) will wait until receiveing a message until it will continue, is there any method to overcome this? Like check it, and if nothing is received at the moment continue?
Check socket.setblocking 
!d socket.socket.setblocking
socket.setblocking(flag)```
Set blocking or non-blocking mode of the socket: if *flag* is false, the socket is set to non-blocking, else to blocking mode.
This method is a shorthand for certain [`settimeout()`](https://docs.python.org/3/library/socket.html#socket.socket.settimeout "socket.socket.settimeout") calls:
• `sock.setblocking(True)` is equivalent to `sock.settimeout(None)`
• `sock.setblocking(False)` is equivalent to `sock.settimeout(0.0)`
Changed in version 3.7: The method no longer applies [`SOCK_NONBLOCK`](https://docs.python.org/3/library/socket.html#socket.SOCK_NONBLOCK "socket.SOCK_NONBLOCK") flag on [`socket.type`](https://docs.python.org/3/library/socket.html#socket.socket.type "socket.socket.type").
thx
lol the python bot is pretty vool
self.client.connect(self.address)
OSError: [Errno 106] Transport endpoint is already connected```
what does this error mean?
i am pretty sure my client is not connected already
oh nevermind i fixed it
Probably a silly question but...
How do you code ... on linux? I've been using Atom on Windows and running the scripts through powershell.
Now I'd like to use pyats, and that only supports Linux.
Spinning up a VM, using windows linux subsytem, it all seems pretty laborious?
It's probably wrong channel 
WSL is nice solution to start with Linux in my opinion
lol start with zorin, it's basically windows of the linux world, then go on to something like manjaro or smthng and if you wanna advance, go arch, then voila! You're a linux chad
Hi, I'm trying to connect to FileZilla Server, but when I start it, it keeps giving this error message:
And the options are greyed out, so I cant go to settings:
i mean if you want to actually 'code on linux' then you can use a VM or just boot into a linux distro
for coding in linux for compatibility or support, WSL is a good option
Hi, I want to write a program that will capture the network packets and save it to a differen
file every 15 seconds and parallely i want to do an operation(running cicflowmeter) on the "pcap" file. Can someone help me?
The code that I have written is below
from scapy.all import *
import datetime
import time
import threading
pcapfile = ""
def threadWork():
x = datetime.datetime.now().strftime("%m%d%Y%H%M%S")
global pcapfile
pcapfile = x + ".pcap"
csvfile = x + ".csv"
record = AsyncSniffer(iface=interface, store= False,prn= packet_filter, timeout=waitingTime)
record.start()
print("Generating your pcap file, hold on")
while(record.running):
continue
subprocess.run(["sudo","cicflowmeter","-f",pcapfile,"-c",csvfile])
def packet_filter(packets):
wrpcap(pcapfile, packets, append=True)
# sniffer("enp0s3")
interface = "enp0s3"
waitingTime = 15
while True:
lagging = threading.Thread(target=threadWork)
leading = threading.Thread(target=threadWork)
lagging.start()
# time.sleep(waitingTime-2)
lagging.join(timeout= waitingTime)
leading.start()
# time.sleep(waitingTime-2)
leading.join(timeout= waitingTime)
But this code is missing packets of about 7 to 8 sec and I don't know how to minimize it.
Someone please help, I have to finish my final year project and this part is making it inefficient.
I used nfqueue to capture (and modify on the fly) all outgoing packets
Ya here also I am able to capture the packet but on that packet I want to do some operations, which takes time and thus during that time neglecting all the packets
Here I want to run cicflowmeter command
As far as I remember nfqueue will wait for your operation and add packets to queue 
No but here I want that I can save the packet capturing for every duration of say 15 sec and with the captured packet I want to parallely process it to convert it into csv file using cicflowmeter
I don't want to miss a single packet
Check this example
from netfilterqueue import NetfilterQueue
def print_and_accept(pkt):
print(pkt)
pkt.accept()
nfqueue = NetfilterQueue()
nfqueue.bind(1, print_and_accept)
try:
nfqueue.run()
except KeyboardInterrupt:
print('')
nfqueue.unbind()
@clear bobcat ,yaye thank you for your help, but what here I am trying to ask is how to parallely capture the network traffic and at an interval and do some processing on it.
The key is to understand that packets are being send in sequence, unless you have several network interfaces.
With nfqueue you can look at every packet and you can even send them to different queues, process in some intervals and so on. The main feature is to catch all packets, what you do with catched packets is your choice
Ooh thank u @clear bobcat ,I am seeing it in detail
how do i multithread client sockets? so i can establish multiple connections to different hosts at the same time
You can start with understanding what the network is, why it was invented, next what is IP protocol, how it works, next you should take a look at UDP and TCP, differences between those two and possible usages 
got it. can you recommend me some resource? any book/website/or tutorial?
Hmm, I think that I don't know any resources in English language 
You have RFCs but it's not the good point to start
oh, no problem. thanks for the help tho. uhmm, RFC??
For example IP RFC: https://tools.ietf.org/html/rfc791
You can start with Wikipedia articles
Article is from the times when dinos are all around the Earth lol 🦖
at first i read updated on 1349 😂 😂 .
Hey @urban stream, "Computer Networks" by Andrew Tanenbaum is a book I can highly recommend. I've used it for my networking classes at university, it guide you quite well through all the network layers.
thanks, i'll check it out.
how does anyone recommend getting started on python
by not asking a question unrelated to networking in the networking channel in the python server
sorry man
lol try asking in #python-discussion
how to use proxy ?
what do you want to proxy?
Hi! I'm not sure if this is the correct topic but I have a question regarding the request module.
I want to upload an image to a url and get the html data afterwards
url = 'https://smallseotools.com/image-to-text-converter/'
files = {'media': open(r'image.png', 'rb')}
with requests.Session() as s:
r = s.post(url, files=files)
jsonn = json.loads(r.text)
print(jsonn)
this is the code im currently working with
(for context: they're in #help-coconut and the reason this doesn't work for them is because the URL they're making requests to isn't an API endpoint, but a normal page with a text form. That site might not even provide a public API, in fact.)
Can you somehow host a socket server on a cloud platform for free?
like google cloud console, aws etc.
please do ping me if you're answering this
Aws works for free, little complicated to set up tho
I don't have any idea, can you help me?
Ive been through the setup already with someone else, took more then an hour and im in school rn, maybe when i get home
ah sure np
I would start by creating an ccount tho, yes you have to enter bank details but the first year is free
So do I have to enter credit card details too?
I dont have a credit card, I'm 14
Yeah thats what i meant
you have to enter them to set up your account
maybe borrow a parents?
they won't allow me
Then you cant use aws sorry
Ive never used heroku but maybe look into that
then theres the google one you mentioned or microsofts azure maybe? Idk how they work since ive never used them
thanks for your time, I'll look into these
lol i had to sneak out at night to get it when i did that
do look into something like heroku tho
yeah I will
probably not a good idea
lol ik, but it just cost me a couple of pennies
lol
noice
lmao
Hi
I'm going to be creating a python program for networking. It will need to console port in to L2 and L3 Switches and do things such as send commands and catch outputs like a list with all the vlans in it.
Does anyone know the best way/ library I should look at/use
I've used paramiko for this kind of thing in the past but I don't recall it being particularly fun or easy tbh :https://github.com/paramiko/paramiko
How can I use the requests module to work with the mail.tm API?
import requests ## Imports the requests module.
headers = {}
payload = {
"address": "test@example.com",
"password": "password"
}
json = '"address": "test@example.com","password": "password'
r = requests.post("https://api.mail.tm/token", json=json)
print(r)
Currently got this, but keep getting error 400
I'm assuming it's just me, but idk what lol
please ping me if you can help, thanks!
Oh -I think your json string is borked
Just pass the payload dict to the json param
doesn't allow me to i think
I get error 401
Which I guess it is?
waitwait wait i'm stupid
correct 🙂
thanks!
i'm being fucking stupid again
lol
lol np
import requests
import json
headers = {}
payload = {
"address": "example@this.org",
"password": "password was 'ere"
}
making_account_thingy = {
"address": "username@solarunited.org",
"password": "helpmepls"
}
r = requests.get("https://api.mail.tm/me")
print(r)
Now I get error 401, why?
Quick look at their API doc suggests that you need to hit the /token endpoint to get a JWT and then include that token in a header for subsequent requests I think
Not sure I see a /me endpoint in there either tbh
totally understand....
lol
OHHHHHHHH
fuck yeah this is the dumbass me
so im trying to send requests with proxies using the request module. This is what I have so far
import requests
file1 = open('proxies.txt', 'r')
Lines = file1.readlines()
count = 0
# Strips the newline character
count = 0
# Strips the newline character
for line in Lines:
count += 1
ses = ("Line{}: {}".format(count, line.strip()))
url = "https://google.com"
r = requests.post(url,proxies={ses})
print('request sent')```
but for some reason I get
File "C:\Users\clutz\desktop\USB\bot visitors\Main.py", line 17, in <module>
r = requests.post(url,proxies={ses})
File "C:\Users[name]\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users[name]\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users[name]\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\sessions.py", line 520, in request
settings = self.merge_environment_settings(
File "C:\Users[name]\AppData\Local\Programs\Python\Python39-32\lib\site-packages\requests\sessions.py", line 698, in merge_environment_settings
no_proxy = proxies.get('no_proxy') if proxies is not None else None
AttributeError: 'set' object has no attribute 'get'
import requests
headers = {
"Authorization": "token is here"
}
payload = {
"address": "an-email@domain.com",
"password": "password is hereeeeeeeee"
}
making_account_thingy = {
"address": "username@solarunited.org",
"password": "helpmepls"
}
r = requests.get("https://api.mail.tm/me", auth=headers)
print(r)
print(r.text)
Hey, does anybody know why this doesn't work?
Please ping me if you can help, thank you!
Trying to use PySerial to write to a STM32F7 disco board, I've basically got a number of this max length '2.1785714285714284' and want to be able to write that serially through USB, to drive a servo. The programme itself is running from a Linux 18.04 VirtualBox environment running Conda with a 3.7 env. I want to write 1 or 2 dependent on the values I'm pulling from my main code if any examples of my code are needed I can provide them. I've read the API but am unsure how to implement and use it properly, has anyone got any experience doing this before?
my tun0 interface appears to only be operable as root (sudo curl google.com --interface tun0 works, but curl google.com --interface tun0 does not). I do not want my python code running as root. How can I make tun0 useable by non root users
There are several ways to accomplish this depending on what your needs are...
import requests
import json
headers = {
"token": "mytoken"
}
making_account_thingy = {
"address": "username@solarunited.org",
"password": "helpmepls"
}
r = requests.get("https://api.mail.tm/me", headers=headers)
print(r)
print(r.text)
I've tried to do this to access the mail.tm api, but it says this:
<Response [401]>
{"code":401,"message":"JWT Token not found"}
I'm assuming it's an authorization issue, but I don't know how to fix it.
If you can help me, then please ping, thank you!
Hello i need your help. I am working on server and i need auto discovery feature. So i need function, that scans the LAN and then it returns list of online clients (IN: IP of server/Network and mask of Network, OUT: list of online devices).
I found one, but it only scans LAN with /24 prefix. Thank you so much.
P.S. pls ping me, so i do not miss it thanks
looks like your definition of "help" is dissimilar to mine since it looks like you want other people to simply do it for you
what's the point in learning when you can have slavessssss
No i looked it up but i couldn't found anything. So i am asking, if anyone did not found similar library.
??
I could not found library/script, that would do the thing i want (described in my message) so i am just asking if anyone found on internet something like that or used script like that. (reply to @prisma cobalt )
Okay, you mean you couldn't find a library to do the thing described earlier.
However, your earlier message seemed to phrase it as if you wanted someone to do it for you.
just be careful with your wording next time
Yeah sorry 😄
npnp
i cant think of any lib's but in look up "port scanner in python" and you should be able to glean some info from that
import requests
import json
headers = {
"token": "mytoken"
}
making_account_thingy = {
"address": "username@solarunited.org",
"password": "helpmepls"
}
r = requests.get("https://api.mail.tm/me", headers=headers)
print(r)
print(r.text)
I've tried to do this to access the mail.tm api, but it says this:
<Response [401]>
{"code":401,"message":"JWT Token not found"}
I'm assuming it's an authorization issue, but I don't know how to fix it.
If you can help me, then please ping, thank you!
you really want to know the answer to this question lol, youve asked 5 times in the past 2 days
i just can't figure it out haha
i'm very stupid
literally nobody seems to know about the mail.tm API
i dont know the answer to your question so i havent been answering it lol
true true
no lol, for emails most people use smtplib
what's that?
a lib for sending emails in python
I looked into docs, and it seems like you first need to generate api key with /token function and pass the account data there. Then use that token
i have
how can I use the token in later requests though?
It should (?) be enough to do it on the start of the program.
hm, okay, thanks!
You are welcome. Come here with results.
alright, thanks
so it works?
Ok 😄
didn't work lol
import requests
import json
headers = {
"token": "token"
}
payload = {
"address": "address",
"password": "pass"
}
making_account_thingy = {
"address": "username@solarunited.org",
"password": "helpmepls"
}
r = requests.post("https://api.mail.tm/token", json=payload)
print(r)
print(r.text)
r = requests.get("https://api.mail.tm/me")
print(r)
print(r.text)
import requests
import json
payload = {
"address": "address",
"password": "pass"
}
making_account_thingy = {
"address": "username@solarunited.org",
"password": "helpmepls"
}
r_token = requests.post("https://api.mail.tm/token", json=payload)
headers = {
"token": r_token.text
}
r = requests.get("https://api.mail.tm/me", headers=headers)
i think something like this should work
alright, thanks!
didn't work, prolly me tho
