C++\Winsock - Sending std out messages problem 
October 11th, 2008, 06:24 PM
| | Member | | Join Date: Aug 2008 Location: South essex, England Age: 16
Posts: 69
| | C++\Winsock - Sending std out messages problem
Hi,
I've been having trouble recently with sending messages to a client.
The client seems to be recieving the sever output (in the console).
This has completely done me in.
I have noticed it is to do with the buffer size.
For example: -
send(client[i].clientsocket, "-h7-Endlist" , sizeof("-h7-Endlist"), 0); // is the previous send() call
-
send(client[i].clientsocket, client[id].clientname, sizeof(client[id].clientname), 0);
-
send(client[i].clientsocket, " signed in.\n" , sizeof(" signed in.\n") , 0);
Would send ' signed in.'.
And when I do somthing like this: -
send(client[i].clientsocket, "-h7-Endlist" , sizeof("-h7-Endlist "), 0); // is the previous send() call
-
send(client[i].clientsocket, " Says:\n" , 1000, 0);
-
send(client[i].clientsocket, client[id].buf , 1000, 0);
-
Would show something liek:
'beta 6
Adam signed in.'
Where 'beta 6' is displayed in the server console, and strangely gets put into send() function.
Also, this worked perfectly over a LAN connect, but not over a WAN connection.
All required ports are opend and forwarded properly.
Is this my cheesy scripting? or a fixable common error?
| 
October 16th, 2008, 08:54 AM
| | Member | | Join Date: Aug 2008 Location: South essex, England Age: 16
Posts: 69
| |
Can someone please help me with this.
| 
October 16th, 2008, 09:54 AM
|  | AdministratorVoR | | Join Date: Feb 2006 Location: South West UK
Posts: 5,731
| |
If the data is not getting there it is much more likely to be a connection error than a send error.
How did you connect? Was it successful (i.e. not returned errors or error callbacks)?
What were the return values of your send function calls?
| 
October 16th, 2008, 05:32 PM
| | Member | | Join Date: Aug 2008 Location: South essex, England Age: 16
Posts: 69
| |
Thanks for posting,
I never seemed to check for send errors, I see what they return...
| 
November 14th, 2008, 11:19 PM
| | Member | | Join Date: Aug 2008 Location: South essex, England Age: 16
Posts: 69
| |
Bit of a bump...
I made a flash client for it as well.
But, its very odd, it displays data that even hasnt been echoed by the server.
So, Most likely a send() error.
What is the best method of using send?
send(socket, "hello", sizeof "hello", 0),
send(socket, string, sizeof string, 0),
send(socket, "hello", 1000, 0),
or send(socket, string, 1000 , 0); ?
| 
November 26th, 2008, 09:31 PM
| | Member | | Join Date: Aug 2008 Location: South essex, England Age: 16
Posts: 69
| |
Please?
Could the environment affect its behaviour?
It works fine on local host, just not on another pc...
|  | | Thread Tools | Search this Thread | | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,662 network members.
|