declaration problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • devi thapa

    declaration problem

    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
  • Marc 'BlackJack' Rintsch

    #2
    Re: declaration problem

    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

    Comment

    • Steve Holden

      #3
      Re: declaration problem

      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



      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/

      Comment

      Working...