By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

declaration problem

P: n/a
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
Nov 7 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Fri, 07 Nov 2008 16:05:22 +0530, devi thapa wrote:
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
Nov 7 '08 #2

P: n/a
Marc 'BlackJack' Rintsch wrote:
On Fri, 07 Nov 2008 16:05:22 +0530, devi thapa wrote:
>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.
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
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Nov 7 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.