473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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
Nov 7 '08 #1
2 1191
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andrew Ward | last post by:
Hi All, Could someone please tell me why this code does not compile. struct A {}; struct B { B(A &) {} }; struct C {
16
by: Bhushit Joshipura | last post by:
This post contains one question and one proposal. A. May I know why order of evaluation of arguments is not specified in C/C++? I asked a question in comp.lang.c++ for the following...
16
by: Vu Pham | last post by:
I think this problem relates to either c or c++ ( but I am not sure which one ) so I post to both of these news group. I am sorry if I did something wrong here. Is there any difference between...
3
by: François Côté | last post by:
I'm generating a TLB from one of my assemblies that contains an interface declaration. The class that implements this interface is in another assembly. I import this tlb in my C++ code to create...
2
by: Legendary Pansy | last post by:
Hello, I'm trying to accomplish the impossible by trying to do something equivalent of this example found here http://www.c-sharpcorner.com/Code/2003/Dec/DialogTutorial.as Starting with "Listing...
3
by: Henning Hasemann | last post by:
Hi all, On larger projects I used the following 'technique' (well in fact its a really simple thing): 1. Write one source-code file for each 'large' class and one corresponding header file....
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
2
by: Alan | last post by:
Does a template class declaration, like template <class T> have to come immediately prior to the declaration of the function, e.g., T do_something (T something) { . . . } that uses it?
1
NeoPa
by: NeoPa | last post by:
Problem Description : In VBA there is an option to enforce declaration of variables in your code. With this set, any reference to a variable that has not been previously declared (Dim; Private;...
6
by: WaterWalk | last post by:
I find friend declaration just very tricky. I tried the following examples on both MingW(gcc 3.4.2) and VC++ 2005. The results are surprising. Example1: namespace ns1 { class Test { friend...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.