+ 7

[Python] Takes One Argument ??? Please Help Me To Fix It 😢

Python Networking is one of python advanced levels I'm new at this level so I have a question , if you are someone who took a look at python networking of course your remember the "bind((host, port))" right ? so what I'm trying to do here is to use qpython3 app to build my apps but the problem here that it tells me that it needs a tuple for the "bind()" I tried to make a tuple but didn't work and it tells me "bind() takes exactly a one argument" it works for me on SoloLearn's Playground but not on qpython

8th Nov 2017, 3:47 PM
warlord
warlord - avatar
9 Answers
+ 8
@Niawahta i tried i removed the help.txt statement it's just the loops ( time limit exceeded) :p but I'm talking about the bind() statement in SoloLearn it works but not on qpython I don't know why
8th Nov 2017, 3:57 PM
warlord
warlord - avatar
+ 7
here's my code for this question https://code.sololearn.com/cbyV3B1cF03T/?ref=app
8th Nov 2017, 3:47 PM
warlord
warlord - avatar
+ 7
@LunarCoffee I will tell you what is the error when I write the code like this: server.bind((host, port)) it tells me this error: bind takes exactly one argument 2 given but when I write like this: server.bind(host) or something like that :p it tells me it should be a tuple
10th Nov 2017, 6:48 AM
warlord
warlord - avatar
+ 7
@LunarCoffee by the way I tried to set the host and the port as a tuple like this: host = server.gethostname() port = 9999 tuple = (host, port)
10th Nov 2017, 6:50 AM
warlord
warlord - avatar
+ 6
@LunarCoffee do you see all of this code it works on SoloLearn but not on "qpython3" ( Python 3 Environment For Android ) qpython is weird cause sometimes when you ask it for an example it will show you but when you compile it ( Run ) it doesn't work and sometimes it doesn't support the socket module objects too much as SoloLearn does I tried the thing that you did but it won't work on qpython just works on SoloLearn
11th Nov 2017, 6:52 AM
warlord
warlord - avatar
+ 4
Remove the open help.txt statement. Traceback info is quite useful, you know. Also, networking! :D
8th Nov 2017, 3:55 PM
LunarCoffee
LunarCoffee - avatar
+ 3
It works for me, in QPython. Look at the info in the traceback error, and post please, thanks. (oh yeah, also, name change)
10th Nov 2017, 4:18 AM
LunarCoffee
LunarCoffee - avatar
+ 3
Hm... it should work with socket.bind((host, port)). Weird. Well... sorry. EDIT: Maybe try removing the variable declaration, just put the statement. You shouldn't need a variable for that. So that line should be: server.bind((host_name, port)) instead of: host_info = server.bind((host_name, port)).
11th Nov 2017, 12:29 AM
LunarCoffee
LunarCoffee - avatar
+ 2
Well, I can do things with the socket module in QPython3, I dunno what's up. I can host my chat server (in development) and run the client on a new terminal process at the same time. Weird.
11th Nov 2017, 3:03 PM
LunarCoffee
LunarCoffee - avatar