Connecting Tech Pros Worldwide Forums | Help | Site Map

C++\Winsock - Sending std out messages problem

Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#1: Oct 11 '08
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:
Expand|Select|Wrap|Line Numbers
  1. send(client[i].clientsocket, "-h7-Endlist" , sizeof("-h7-Endlist"), 0); // is the previous send() call
  2. send(client[i].clientsocket, client[id].clientname, sizeof(client[id].clientname), 0);
  3. send(client[i].clientsocket, " signed in.\n" , sizeof(" signed in.\n") , 0);
Would send ' signed in.'.
And when I do somthing like this:
Expand|Select|Wrap|Line Numbers
  1. send(client[i].clientsocket, "-h7-Endlist" , sizeof("-h7-Endlist                                 "), 0); // is the previous send() call
  2.     send(client[i].clientsocket, " Says:\n" , 1000, 0);
  3.     send(client[i].clientsocket, client[id].buf , 1000, 0);
  4.  
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?

Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#2: Oct 16 '08

re: C++\Winsock - Sending std out messages problem


Can someone please help me with this.
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,195
#3: Oct 16 '08

re: C++\Winsock - Sending std out messages problem


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?
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#4: Oct 16 '08

re: C++\Winsock - Sending std out messages problem


Thanks for posting,
I never seemed to check for send errors, I see what they return...
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#5: Nov 15 '08

re: C++\Winsock - Sending std out messages problem


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); ?
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
#6: Nov 26 '08

re: C++\Winsock - Sending std out messages problem


Please?
Could the environment affect its behaviour?
It works fine on local host, just not on another pc...
Reply