#networks

1 messages · Page 30 of 1

prisma cobalt
#

I made one :)

#

Check this channels pins

shy island
#

👀 latest pin?

#

oki

prisma cobalt
#

If you need anymore help @shy island then ping me

shy island
prisma cobalt
#

Have you got a server and client script finished?

shy island
#

yes

prisma cobalt
#

Nice, do you know how to find your public IP address?

shy island
#

no

#

i just know about ipconfig

prisma cobalt
#

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

shy island
prisma cobalt
#

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

shy island
#

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

prisma cobalt
#

Yeah that's possible with sockets

shy island
#

damn

#

aight

#

lemme go through the website

prisma cobalt
#

Website?

shy island
#

i mean ur pinned link xd

prisma cobalt
#

Ah right lmao

turbid zinc
#

Hello does anyone know how to work with rak-net in Python?

#

I need help getting started with it

midnight slate
#

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

prisma cobalt
latent socket
#

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

gloomy root
#

socket server module?

#

what are you trying to do firstly

placid fractal
#

do u mean socket.socket and socket.create_server?

prisma cobalt
#

no it is that

placid fractal
#

socketserver module uses the socket library but makes it easier

gloomy root
#

again this really depends on what you're trying to do bloblul

placid fractal
#

true

prisma cobalt
#

lmao

midnight mural
#

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

foggy moon
#

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/

midnight slate
#

how to convert a list to bytes

merry hornet
#

i have a ONOS SDN controller
how can i write a script to monitor the traffic on it ?

plain girder
#

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

latent socket
#

In tcp after 1024 bytes it will break your data but i dont want it

#

I want a efficient version of socket (server side)

trim moth
#

So you can keep sending and receiving data in a while true loop till theres no data to send

latent socket
#

Yeah exactly i did

trim moth
#

Noice

latent socket
#

But in some times it appends next data with old sent data

trim moth
#

Are you working with sending files?

#

Or just sending plain text data

latent socket
#

Text data but still if i send 2 data one after one new data appends to old data

#

Which i dont want

trim moth
#

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

latent socket
#

Suppose i send like this
So.send(1)
So.send(2)
In recving data "2" appends with "1" so full data is now "12"

trim moth
#

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

latent socket
#

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

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?

latent socket
#

thinkmon but it is same thing in a different way next data will also append to that list

trim moth
#

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

latent socket
#

I wanna get rid of new packet in old one

trim moth
#

get rid of new packet in old one?

latent socket
#

Yez as i gave example

trim moth
#

Can you show your code

trim moth
trim moth
latent socket
#

Hmm i will show you

trim moth
latent socket
#

@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
trim moth
#

Hit me up if it works or not lol

modest pebble
#

You should use the chr(255) instead of "¥" to improve readability

trim moth
#

Yeah, but it didn't matter much to me lol

#

@modest pebble bruh we got complementary color schemes going on lol

latent socket
#

i want a full data

trim moth
#

You mean, you want all the data you have entered to be printed right?

latent socket
#

no i want all data in one single string

#

so i can do something

#

by getting half half data its useless

trim moth
#

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

#

🥲

latent socket
trim moth
#

But that gives you your data in one single string lol

latent socket
#

i dont want last sent byte to append in first byte

trim moth
#

Oooh i get it now

latent socket
#

and what he was saying to use chr(255) instead of that ¥ symbol

#

which charecter is 255 ?

trim moth
#

Idk lmao, its same anyways you use chr(255) or that character lol

latent socket
#

🤦‍♂️

trim moth
#
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

trim moth
latent socket
trim moth
#

lol

latent socket
#

i mean for logic less answer 🤦‍♂️

latent socket
#

😒 what space will do

trim moth
#

lmao, what your desired output should look like?

latent socket
#

wait dude let me show you

trim moth
#

yeah 😁

latent socket
#

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

trim moth
#

Hmmmmm

latent socket
#

😑

trim moth
#

Ooff

#

This is hurting my bren

latent socket
#

🥺 😑

trim moth
#

Make it so that on receiving '/ADM' it will not append it to the file like it does everytime

trim moth
latent socket
#

but why just you are replying

#

where are others

trim moth
#

Oh

#

lol ¯\_(ツ)_/¯

latent socket
#

Noice

trim moth
#

Ig that's all a 16yo can help

#

🥲

prisma cobalt
#

who needs help with what?

prisma cobalt
latent socket
#

?

#

@prisma cobalt

prisma cobalt
#

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?

latent socket
#

i cant get it explain with code

#

please

prisma cobalt
#

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)
prisma cobalt
#

so you would send the size of the message in bytes, then send the message

#

get it?

latent socket
#

you sure with multiple clients any request can come at any second you can handle recving 2 times

prisma cobalt
#

yeah there shouldnt be a problem

#

whats your current solution?

latent socket
latent socket
#

read down

prisma cobalt
latent socket
prisma cobalt
#

why are you using os.popen to read a file?

#

@latent socket

latent socket
#

os.popen is a method to use batch commands

#

by using tasklist you can get taskmanager programs list

prisma cobalt
#

ah right

#

yeah you should probably do my method

#

aka: sending the message size AND THEN the message

latent socket
#

what is the efficient method

prisma cobalt
#

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

latent socket
#

the problem is if i sent a 2nd message in that time it also counts that in first message recving

prisma cobalt
#

i think thats cause your += the data

latent socket
#

so your solution also has that

#

so what is the difference

#

@prisma cobalt

prisma cobalt
#

i have no idea its up to you
first solution is probably sends 2 pieces of data per transfer
the second only one

latent socket
#

😒 noice

trim moth
#

@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

latent socket
#

hmm

#

sounds good

trim moth
#

For real? Or u kidding

prisma cobalt
trim moth
wicked sable
#

hi i need help with requests

next jasper
wicked sable
next jasper
#

What do you mean?

velvet lichen
#

code i got on the internet

latent socket
#

I will try

trim moth
#

Yeah

trim moth
latent socket
#

You are very active and friendly☺️ ☺️

trim moth
#

Thanks! Appreciate it

#

It was my pleasure to help you

jovial tide
#

does anyone know how to make a remote desktop gui?

#

i saw you typing

#

píng me if anyone got a anser, please

wide path
#

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 ?

prisma cobalt
neon kiln
#

how i can use like " if end " in python ?

#

i hope you understand what i went 😂 >

wide path
#

@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

mortal sluice
#

Remote Desktop GUI?

#

I suppose it can be done with tkinter, but the actual GUI is opened through a command sent over network connection

prisma cobalt
velvet lichen
#

what is base64??????????????

clear bobcat
bitter agate
#

hi, i need to make a chat in django, can some one help me?

bitter agate
#

?

trim moth
#

@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

trim moth
#

So have you started something yet?

#

lmao

ember ledge
#

can anyone help me how can i make a free server??

prisma cobalt
ember ledge
velvet lichen
#

is that how should i do it?

velvet lichen
#

nvm i screwed it up.... forgot to use sys

cerulean knoll
#

Hey this will be a javascript question

#

Why am i getting undefined in console log?

exotic condor
#

!ot

errant bayBOT
elder spoke
#

Is it possible to connect two clients with voice chat using socket?

prisma cobalt
#

yeah

trim moth
#

Intresting, imma go look into that lmao

opal orbit
#
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?

errant bayBOT
#

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).
ember ledge
#

can anyone help me how can i make a free cloud gaming server

ember ledge
#

i have then you say how can m ake

#

@ember ledge

trim moth
# ember ledge i have then you say how can m ake

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

ember ledge
#

can anyone help me to make a cloud gaming server??

prisma cobalt
ember ledge
#

please help me

prisma cobalt
#

@ember ledge I'm not friending you, talk here on the server

ember ledge
prisma cobalt
prisma cobalt
ember ledge
#

@prisma cobalt

prisma cobalt
#

Go to the pins of this discord channel and look at the 2nd one

#

Thats a basic server

ember ledge
#

so what i will do next

prisma cobalt
#

There are resources on that pin

trim moth
#

@ember ledge try googling about how people set up minecraft servers

ember ledge
#

not mineraft server

trim moth
#

ik

#

all that differs in your idea is the game you want to run pretty much all the other things remain the same

prisma cobalt
ember ledge
prisma cobalt
#

In python? Good luck mate

trim moth
#

bruh

#

lmao

inland rampart
#

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?

ember ledge
#

i want to upload that game in my server

#

@inland rampart

inland rampart
#

Upload? So it's not a game you're developing? how is that Python-related though?

ember ledge
#

i am facing issue so i am asking

prisma cobalt
#

Wait, are you or are you not making your own game?

latent socket
ember ledge
#

so for that i want a server

latent socket
ember ledge
prisma cobalt
#

Okay you could make a script in python to handle clients

latent socket
#

Best one is aws

#

@ember ledge

prisma cobalt
ember ledge
latent socket
prisma cobalt
#

I've given you socket resources AND an example code

#

Please use those

latent socket
ember ledge
#

and how to make

prisma cobalt
#

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

ember ledge
#

ok

#

after by using that where i will run

#

and what output it will give

#

and where to run

prisma cobalt
#

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

ember ledge
#

so i am the owner so i cannot make a server so i am taking help from you

prisma cobalt
#

As the owner will you be writing the code?

#

If not then anything I tell you here is pointless

ember ledge
#

i am the story maker

#

and scripting

prisma cobalt
#

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?

ember ledge
#

bro error is coming during running in vs code

#

getaddrinfo failed these error is coming

prisma cobalt
#

I thought you weren't coding?

ember ledge
prisma cobalt
#

So not python?

ember ledge
prisma cobalt
#

Does the coder on your team know python?

#

I assume your doing this in python

ember ledge
ember ledge
prisma cobalt
ember ledge
#

he is making in unity

#

so he knows c#

prisma cobalt
#

But python?

ember ledge
#

he knows

prisma cobalt
#

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

ember ledge
#

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

trim moth
#

i suggesting completely neglecting python here

prisma cobalt
prisma cobalt
#

Python is quick and easy but for a full game will be hard to use

trim moth
#

he's not a bit interested in python and just wants a way to get his game on a server

prisma cobalt
#

Are you hosting yourself?

trim moth
#

lmao

ember ledge
prisma cobalt
#

No no no, sure your hosting your game but the machine that your hosting on. Is it yours?

trim moth
#

and is it a server or your PC you're hosting on

prisma cobalt
#

Like do you physically own it?

ember ledge
#

so i want to host there

trim moth
#

noice

ember ledge
#

ryzen 5 4600h,8gb ram.512 gb ssd,gtx 1660 ti 6gb graphics dedicated and 3 gb radeon graphics intergrated

prisma cobalt
#

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

trim moth
#

wow

ember ledge
#

and do for that

prisma cobalt
#

What type of game is it?

trim moth
#

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

ember ledge
trim moth
#

as of running it on a server, it's just to provide the ip and the port for the clients to connect

prisma cobalt
#

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

trim moth
#

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

ember ledge
prisma cobalt
#

FFS listen to us instead of spamming the same question :(

ember ledge
#

after the game ready can you host the game on the server

trim moth
#

nooo nooo

#

shit i messed up

#

anyways, gotta go for dinner lol byeee

prisma cobalt
#

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

trim moth
#

on point my man

ember ledge
prisma cobalt
#

why would i do that for you? besides i dont know C# very well which is what your coder is using with unity.

prisma cobalt
#

this is a job for your coder to implement @ember ledge you cant do any more

ember ledge
#

and i also cannot do

prisma cobalt
#

and bear in mind that this task is a huge one, its not easy implementing networking

prisma cobalt
ember ledge
prisma cobalt
#

well then your stuck, unless you pay someone to do it for you which will be expensive

trim moth
ember ledge
dim blade
#

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

inland rampart
#

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.

velvet lichen
#

hello networking people

prisma cobalt
#

ello

fair dock
#

Is there a scapy discord?

trim moth
#

got any memess?

#

lmao

opal orbit
#

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?

velvet lichen
#

i found out that kahoot stole a loop from garageband doe

bold pond
#

hi does anyone know how to make a client-client interaction via a server ofc

errant bayBOT
ember ledge
#

fuck you

velvet lichen
#

lol

faint hemlock
trim moth
#

lol

long flume
#

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/

prisma cobalt
trim moth
#

Oh, y u do dis?
Don't do dat here pless

desert ridge
#

Any of yous have any idea why my (first) Flask app isn't showing up on anouther computer within the same local (VPN) network?

prisma cobalt
desert ridge
#

Yes, I'm trying to connect externally to the IPv4:5000

kind furnace
#

@desert ridge server is windows / linux, and what is client?

dense spruce
#

goodday, looking for recommendations on books/online resources on sockets

#

or is man pages as good as it gets

ember ledge
#
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

molten anchor
#

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

ember ledge
#

my token isn't there is it?

spring wigeon
#

my bad 😬

ember ledge
#

but thanks for being a bro

#

sorry for sounding rude, i didn't mean to, i only realized it now, thank you for worrying

spring wigeon
#

You didn't sound rude at all, no worries.

bold pond
#

hi does anyone know how to make a client-client interaction via a server ofc

abstract crest
#

To host to the VPN you need discover what is your pc IP in the VPN

abstract crest
desert ridge
#

I was trying externally connect to the IPv4

abstract crest
#

you cant host on localhost and access trough other devices

desert ridge
#

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?

kind furnace
#

@desert ridge with flask running, can you try to telnet <windows_ip> <fask-port-number> # from the client

desert ridge
#

Apparently I can't install telnet:

abstract crest
#

You need host on 172.20.2.101

#

to make visible to other devices

prisma cobalt
#

127.0.0.1 is localhost only like you said

abstract crest
#

and, being in japan, i can access from my phone the host that is in the US only typing 0.0.0.0?

prisma cobalt
#

well your public ip factors into it

tough dagger
#

Guys guys

#

It's for binding network interface not for connecting to it

prisma cobalt
#

exactly

#

socket.bind((0.0.0.0, port)) "bind" with "0.0.0.0" allows incoming connections

storm bison
#

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

rare bough
#

is this a good place to look for a help with communicating via bluetooth?

ember ledge
#

hi

trim moth
trim moth
split idol
#

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

split idol
#

i dont want to close the socket

trim moth
#

oh

split idol
#

i want my chat app to keep working after the image is sent

trim moth
#

so just dont't call it

#

and continue with you chatting code

#

lol

split idol
#

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

trim moth
#

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

split idol
#

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)

trim moth
#

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?

split idol
#

k ill try that out

trim moth
#

lol

#

do tell me if that works or not

split idol
#

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

trim moth
#

wierd indeed

errant bayBOT
trim moth
#

f u

errant bayBOT
#

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.

trim moth
#

let it be

trim moth
#

lmao

lost hatch
#

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.

trim moth
#

@lost hatch just start a timer lmao and if it exceeds 14 seconds, call exit()

#

or close the socket

lost hatch
opal orbit
#
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

dense spruce
#

are you getting that error when u run it? It's running fine here

tough dagger
# split idol the output also is very weird ```py file = open(f'data/image#{3}.png', 'wb') pri...

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.

tough dagger
tough dagger
errant bayBOT
tough dagger
# storm bison And the other person doesnt have to be on the same internet as us

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.

ember ledge
#

Does anyone use UDP socket?

prisma cobalt
#

tcp is more common tho i think

#

since its lossess to an extent

tough dagger
# ember ledge Does anyone use UDP socket?

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

trim moth
#

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

ember ledge
#

i get the error



on socket.io.js:1
pls help

atomic osprey
#

What are the headers set in CORS and how do their values affect things?

gloomy root
#

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...

vapid swift
#

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?

cold sphinx
#

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.

dense spruce
vapid swift
#

i got it to work now it was a server side issue on the server hosting the file

dense spruce
#

👍

rotund grove
#

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

pure furnace
#

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

void wraith
#

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.

cold sphinx
#

Yeah its just a website

void wraith
#

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?

cold sphinx
#

Yeah same errors

#

if its being blocked ill have to figure out away around it

void wraith
#

hm yea good luck with it 😦

limpid bay
#

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?

lament dagger
tough dagger
ember ledge
thorny talon
#

How to get an OAuth2 authorised session in aiohttp?

brisk comet
#

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?

trim moth
#

Decide based on the content of the acknowledgement message that which device it is

#

?

brisk comet
#

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?

cold sphinx
empty rune
#

anyone know a python curl library because PYcURL is python 3.8 and i have python 3.9

frozen drum
#

why do you need a library?

#

you can't use something like subprocess.run() ?

empty rune
#

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)

empty rune
#

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

gloomy root
#

getattr

ember ledge
#

udp proxy server

I want to create a proxy server.
But it hasn't been realized yet.
who can help me?

  1. Quickly modify the data package.
  2. Port multiplexing.
empty rune
#

#web-development message (cross channel posting because it may fit here but i dont want to spam the information which was allready posted)

clear rock
#

does socket have a readexactly method? i want to receive a specific amount of bytes, and the size is given by the header

gloomy root
#

mmm not really because it's fairly low level

#

it'd just be a while loop though reading until the amount is satisfied

clear rock
#

oh

#

ill do that then

tough dagger
clear rock
#

hmm well the maximum amount of bytes is going to be around 12k

tough dagger
#

It's too big

clear rock
#

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
tough dagger
#

Why not ? It will work but how do you know n ?

#

Send it first before the message

clear rock
#

alright

prisma cobalt
gloomy root
#

that depends on your configuration but yes it can

clear rock
#

that could receive lower bytes than that sometimes right?

gloomy root
#

though IIRC it's not garenteed

#

it reads upto that amount

#

but you dont get that amount garenteed

prisma cobalt
#

yeah my bad, shouldve said that as well lol

clear rock
prisma cobalt
#

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?

clear rock
#

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

tough dagger
#

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

clear rock
#

oh, so BytesIO?

tough dagger
#

Or bytes

#

Sends over TCP may be merged but it's not guaranteed I think at least

prisma cobalt
gloomy root
#

What are you actually trying to achieve here

clear rock
#

well

gloomy root
#

it's sorta sounding like you want a HTTP server rather than raw sockets like this

clear rock
#

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

gloomy root
#

You should probably use a higher level system for this

prisma cobalt
#

ooo cross platform, interesting

gloomy root
#

if its just a board game HTTP is probably the easiest and most reliable

prisma cobalt
clear rock
#

oh

prisma cobalt
#

altho it would be easier yeah probably

gloomy root
#

sure, but you're gonna end up doing HTTP style anyway

prisma cobalt
#

lmao

#

why reinvent the wheel then, use http or something similar

clear rock
#

so websockets?

gloomy root
#

Like data flow and data management with sockets is a masiveeeee pain in the ass

#

websockets would work yeah

gloomy root
#

have one player essentially be the host, others be the client

clear rock
#

wait

#

i want server client connection :(

#

not peer to peer

prisma cobalt
#

thats fine too

gloomy root
#

thats what websockets are

#

websockets aren't P2P

clear rock
#

oh okay, i think sockets is more suited for P2P

prisma cobalt
#

theres some confusion i think, i gather vinam wants to use an external server instead of a player server

prisma cobalt
clear rock
#

cause my program works on localhost and local network fine

gloomy root
#

I think you might miss understand what P2P means

clear rock
gloomy root
#

everything network based is built around sockets

clear rock
#

the player hosts the server

#

?

north igloo
gloomy root
#

P2P is client to Client with no server intermediate

prisma cobalt
#

okay im gonna give you a solution Vinam, give me a sec

gloomy root
#

!paste

errant bayBOT
#

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.

prisma cobalt
#

before i start i assume you have an external server your running yourself?

clear rock
#

yes, on a vps

prisma cobalt
#

yep okay

tough dagger
# prisma cobalt 😂 yeah

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

prisma cobalt
#

this is how to circumvent port forwarding as well (for the clients, not your server):

clear rock
gloomy root
#

You'd end up with about 500+ lines of code to make a proper socket system like that

#

speaking from experience

clear rock
#

welp

gloomy root
#

it takes alot of data management with raw sockets

#

HTTP and websockets is by far the simplest and easiest method

prisma cobalt
#
  1. make each client connect to the server you have running
  2. 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

clear rock
#

oh, ill go try out http.. gotta learn it first

prisma cobalt
#

i dont think messages for a boardgame will be that big

prisma cobalt
clear rock
#

so messages are just 6 bytes

#

but

prisma cobalt
#

lmao

clear rock
#

when 2 clients connect

#

i need to board data to both

#

from server

gloomy root
#

just have the server echo the client message to the others

clear rock
#

thats like one 10 by 10 2 dimensional array

#

a bool and some more data

prisma cobalt
#

Yeah so not much data

clear rock
#

it becomes 12k bytes though

#

12163, specificially

#

or 12162, depending on the bool

prisma cobalt
#

If you already know the size of the message then why are you worrying?

#

I would use sockets in that case

tough dagger
#

9 TCP/IP packets is not end of the word.

clear rock
#

i wouldnt even be worrying if i didnt get incomplete packets in a linux client thinkies, idk the reason but i want to know how it works for windows

tough dagger
#

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)

clear rock
#

oh

tough dagger
#

So yeah that's why it comes to you chunked, but you shouldn't rely on that

clear rock
#

but shouldnt socket.recv ensure that every packet is reached and then return the data?

prisma cobalt
#

You seem very knowledgeable @tough dagger lol

clear rock
#

or does it return each packet KokoroEyes

prisma cobalt
#

Returns each packet

clear rock
#

oh damn

prisma cobalt
#

You can get sendall and you can implement your own recvall tho

clear rock
#

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 FlanThink

prisma cobalt
#

Lmao

tough dagger
#

Localhost is not network really

clear rock
#

yeah...

tough dagger
#

It's a loopback device

#

It might go to driver and back so has some latency but not real one

clear rock
#

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

prisma cobalt
tough dagger
#

Send something small first or fit message in some buffer after header and then send

clear rock
#

12k in the start, 6 when the game is running

clear rock
#

and it should be small enough to fit in a packet

tough dagger
#

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

clear rock
#

oh

prisma cobalt
tough dagger
#

For the basics yeah

prisma cobalt
#

👍

tough dagger
#

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)

gloomy root
#

it either gives you a Content-Length or Transfer-Encoding: chunked or None in which case the default is 0

clear rock
#

do i send the header through the json?

#

hmm

prisma cobalt
#

no? wait what is that question, maybe im being dumb

gloomy root
#

This sorta goes back to the whole HTTP thing i suggested

clear rock
#

idk how to send a header KoishiDerp

gloomy root
#

headers are just a virtual thing, not a direct TCP thing

tough dagger
gloomy root
#

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

clear rock
#

yeah..

gloomy root
#

HTTP looking pretty 👌 rn

prisma cobalt
#

lol, didnt think i was going crazy

prisma cobalt
#

im new to this side of networking

gloomy root
#

well no just use HTTP and WS

prisma cobalt
#

ah i dont know really how that works lol, something to research i guess

#

im more of a traditional socket person

gloomy root
#

you basically start with a HTTP request and it gets upgraded to WS via a upgrade call

prisma cobalt
#

whats WS?

gloomy root
#

websocket

tough dagger
#

Web socket is just a socket and bootstrap of http

prisma cobalt
#

ahh

tough dagger
#

Like mentioned

prisma cobalt
gloomy root
#

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 😉

prisma cobalt
#

ohhh

#

but its build on top of sockets (with a HTTP aspect added)?

gloomy root
#

Just hide the messy logic under the hood WinkBadge

#

yes basically

tough dagger
gloomy root
#

has a great demonstration and break down

prisma cobalt
#

thx man

clear rock
#
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))

tough dagger
#

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

clear rock
tough dagger
#

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

clear rock
#

😩

#

ahhh

#

ill just go learn http

tough dagger
#

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

clear rock
#

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

#

ferristhumbsup done now time to check on vps

fresh bear
#

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?

tough dagger
prisma cobalt
#

i dont think REPL allows connections...

clear rock
#

omg yes

#

it works on the vps too

#

thanks guys

prisma cobalt
#

they cant assign an ip to every REPL since there are thousands

clear rock
prisma cobalt
#

can i see your code @clear rock

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)```
prisma cobalt
#

thats the server?

clear rock
#

both actually

#

i use the same send and receive method for client and server

prisma cobalt
#

so your using normal sockets instead of HTTP?

clear rock
#

i have a common Network class

#

yess

prisma cobalt
#

nice

tough dagger
#

Yup minimal working set and if it works well 😊 it's enough

prisma cobalt
#

I always prefer lower level stuff over higher level stuff

#

Makes it more interesting

ember ledge
#

Hi,
is there anyone familiar with ZeroMQ (async pyzmq)?

tough dagger
#

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

ember ledge
ember ledge
north igloo
#

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?

clear bobcat
#

!d socket.socket.setblocking

errant bayBOT
#

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").
north igloo
#

thx

trim moth
#

lol the python bot is pretty vool

clear rock
#
  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

deft thistle
#

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?

clear bobcat
trim moth
#

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

storm bison
#

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:

storm saffron
#

for coding in linux for compatibility or support, WSL is a good option

fluid swan
#

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.

clear bobcat
fluid swan
#

Here I want to run cicflowmeter command

clear bobcat
fluid swan
#

I don't want to miss a single packet

clear bobcat
#

Why do you capture them in parallel?

#

!pypi NetfilterQueue

errant bayBOT
clear bobcat
# fluid swan 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()
fluid swan
#

@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.

clear bobcat
fluid swan
#

Ooh thank u @clear bobcat ,I am seeing it in detail

ember ledge
#

how do i multithread client sockets? so i can establish multiple connections to different hosts at the same time

urban stream
#

how to start learning networking?

#

not only by using python, but as a whole

clear bobcat
# urban stream how to start learning networking?

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 pithink

urban stream
clear bobcat
#

You have RFCs but it's not the good point to start

urban stream
clear bobcat
#

You can start with Wikipedia articles

clear bobcat
urban stream
#

at first i read updated on 1349 😂 😂 .

obsidian escarp
#

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.

solar pecan
#

how does anyone recommend getting started on python

prisma cobalt
solar pecan
#

sorry man

trim moth
iron phoenix
#

how to use proxy ?

kind furnace
gentle tusk
#

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

#

this is the code im currently working with

whole prawn
#

What's the problem?

#

You can use ```py
jsonn = r.json()

#

also

inland rampart
# whole prawn What's the problem?

(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.)

light zealot
#

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

prisma cobalt
light zealot
prisma cobalt
light zealot
#

ah sure np

prisma cobalt
# light zealot ah sure np

I would start by creating an ccount tho, yes you have to enter bank details but the first year is free

light zealot
#

I dont have a credit card, I'm 14

prisma cobalt
#

you have to enter them to set up your account

#

maybe borrow a parents?

light zealot
#

they won't allow me

prisma cobalt
#

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

light zealot
#

thanks for your time, I'll look into these

trim moth
#

do look into something like heroku tho

light zealot
#

yeah I will

light zealot
trim moth
#

lol ik, but it just cost me a couple of pennies

light zealot
#

lol

trim moth
#

heroku is completely free tho

#

no catches there

light zealot
#

yeah, I had hosted my django website on heroku

#

probably a month ago

trim moth
#

noice

prisma cobalt
#

show us the code

#

huh?

trim moth
#

lmao

radiant vortex
#

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

whole prawn
#

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

GitHub

The leading native Python SSHv2 protocol library. Contribute to paramiko/paramiko development by creating an account on GitHub.

pure furnace
#

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!

whole prawn
#

Just pass the payload dict to the json param

pure furnace
#

I get error 401

whole prawn
#

Yeah

#

Which is the correct error if the user/pass is wrong

pure furnace
#

oh

#

lol

whole prawn
#

Which I guess it is?

pure furnace
#

waitwait wait i'm stupid

pure furnace
#

thanks!

#

i'm being fucking stupid again

#

lol

whole prawn
#

lol np

pure furnace
#
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?

whole prawn
#

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

pure furnace
#

lol

#

OHHHHHHHH

#

fuck yeah this is the dumbass me

rocky dirge
#

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'

pure furnace
#
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!

lucid lintel
#

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?

primal moon
#

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

ember ledge
#

There are several ways to accomplish this depending on what your needs are...

pure furnace
#
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!

opaque nymph
#

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

prisma cobalt
pure furnace
#

what's the point in learning when you can have slavessssss

opaque nymph
#

No i looked it up but i couldn't found anything. So i am asking, if anyone did not found similar library.

pure furnace
#

??

opaque nymph
# pure furnace ??

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 )

pure furnace
#

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

opaque nymph
#

Yeah sorry 😄

pure furnace
#

npnp

prisma cobalt
pure furnace
#
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!

prisma cobalt
pure furnace
#

i just can't figure it out haha

#

i'm very stupid

#

literally nobody seems to know about the mail.tm API

prisma cobalt
#

i dont know the answer to your question so i havent been answering it lol

pure furnace
#

true true

prisma cobalt
pure furnace
#

what's that?

prisma cobalt
#

a lib for sending emails in python

pure furnace
#

oooooooohhhhhhhhhh

#

does it have something for tempmails?

opaque nymph
pure furnace
#

how can I use the token in later requests though?

opaque nymph
#

It should (?) be enough to do it on the start of the program.

pure furnace
#

hm, okay, thanks!

opaque nymph
#

You are welcome. Come here with results.

pure furnace
#

alright, thanks

opaque nymph
#

so it works?

pure furnace
#

idk haha

#

not had time to try

opaque nymph
#

Ok 😄

pure furnace
#
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)
opaque nymph
#
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

pure furnace
#

alright, thanks!

opaque nymph
#

Maybe you will need to edit it a little bit

#

You are welcome

pure furnace
#

didn't work, prolly me tho