declaration problem

D

devi thapa

Hi,

I am using the command

recv(..) to receive a message from client.

retval = recv(my_socket, *buf, len(buf) , 0)

and its giving this error

File "./server1.py", line 31
retval = recv(my_socket, *buf, len(buf) , 0)
^
SyntaxError: invalid syntax

how should I fill the length parameter,

please help me out with this,

Regards,
Devi
 
M

Marc 'BlackJack' Rintsch

I am using the command

recv(..) to receive a message from client.

retval = recv(my_socket, *buf, len(buf) , 0)

and its giving this error

File "./server1.py", line 31
retval = recv(my_socket, *buf, len(buf) , 0)
^
SyntaxError: invalid syntax

``*buf`` means "unpack everything in `buf` as if it where written as
positional arguments". It is not some "pointer dereferencing" syntax, as
Python doesn't have pointers as data types. After argument unpacking it
is not allowed to have other positional arguments. That's the syntax
error.

From where do you get `recv()` anyway? And what is `my_socket`? Most
certainly not an instance created with `socket.socket` because then you
would use the `recv()` method of that object.

Ciao,
Marc 'BlackJack' Rintsch
 
S

Steve Holden

Marc said:
``*buf`` means "unpack everything in `buf` as if it where written as
positional arguments". It is not some "pointer dereferencing" syntax, as
Python doesn't have pointers as data types. After argument unpacking it
is not allowed to have other positional arguments. That's the syntax
error.

certainly not an instance created with `socket.socket` because then you
would use the `recv()` method of that object.
It's C, loosely transcribed as pseudo-Python. For some clues about
networking, take a look at

http://holdenweb.com/docs/NetProg.pdf

but this does assume you want to learn Python, not carry on writing C.

[Jack, the above is address to Devi, not you].

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top