Connecting Tech Pros Worldwide Help | Site Map

C++\Winsock - Sending std out messages problem

  #1  
Old October 11th, 2008, 07:24 PM
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82
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?
  #2  
Old October 16th, 2008, 09:54 AM
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82

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


Can someone please help me with this.
  #3  
Old October 16th, 2008, 10:54 AM
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,117
Provided Answers: 6

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?
  #4  
Old October 16th, 2008, 06:32 PM
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82

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


Thanks for posting,
I never seemed to check for send errors, I see what they return...
  #5  
Old November 15th, 2008, 12:19 AM
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82

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); ?
  #6  
Old November 26th, 2008, 10:31 PM
Member
 
Join Date: Aug 2008
Location: South essex, England
Posts: 82

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