![]() |
| | #1 |
| 30 Helens Agree Join Date: Jan 2002
Posts: 607
| problem with send function Code:
//typical call would be ::perSend(crchat, 1024);
//usually though, the crchat is not 1024 in length. i've tried adding an if(...)break to stop
//when the delimiter was hit, but it didn't do anything.
INT PEER::perSend(CHAR *databuff, INT len)
{
char *zbuff = databuff;
while (len > 0)
{
iSentBytes = send(sckPeer, zbuff, 1, 0);
if (iSentBytes == SOCKET_ERROR)
{
if ((iError = WSAGetLastError()) != WSAEWOULDBLOCK)
return -1;
}
iTSentBytes += iSentBytes;
zbuff++;
len--;
}
return iTSentBytes;
}
__________________ AIM: Neandrake EMAIL: nta0 @ yahoo . com Operating System: Windows XP SP2 Compiler: GCC IDE: Notepad++ Don't give up your freedom to think - www.cognitiveliberty.org |
| neandrake is offline | |
| | #2 |
| Gawking at stupidity Join Date: Jul 2004
Posts: 2,324
| What delimiter? Have you tried running your program through a debugger to see what's going on? Why are you sending the characters one at a time instead of all at once?
__________________ If you understand what you're doing, you're not learning anything. Ignore any "advice" esbo tries to give you. It's wrong. |
| itsme86 is offline | |
| | #3 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,700
| > if ((iError = WSAGetLastError()) != WSAEWOULDBLOCK) And if it is WOULDBLOCK, you skip a character and try and send the next one? Do you have something else which you can usefully do for a few mS whilst the network clears some of the backlog? How about trying to send as much as possible with each send call, since it returns with the actual amount sent. Using this its possible to advance through the message buffer. Code: while (len > 0)
{
iSentBytes = send(sckPeer, zbuff, len, 0);
if (iSentBytes == SOCKET_ERROR)
{
if ((iError = WSAGetLastError()) != WSAEWOULDBLOCK)
return -1;
}
else
{
iTSentBytes += iSentBytes;
zbuff += iSentBytes;
len -= iSentBytes;
}
}
|
| Salem is offline | |
| | #4 |
| 30 Helens Agree Join Date: Jan 2002
Posts: 607
| thankyou both for replies. I had originally the function to send everything at once, but I had problems with receiving only the first character 1024 times. I changed it this way and it seemed to work. I will definately try salem's approach, however I did some more debugging, and the lag occurs after the perSend function. So it must be a windows thing. the call is sent from a dialog process function, and there is no lag if the perSend function is not called. But the lag occurs after the send (which nothing else happens, except a return to end the function).
__________________ AIM: Neandrake EMAIL: nta0 @ yahoo . com Operating System: Windows XP SP2 Compiler: GCC IDE: Notepad++ Don't give up your freedom to think - www.cognitiveliberty.org |
| neandrake is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pure virtual function mixed with regular virtual function problem | johnnyboldt | C++ Programming | 3 | 10-28-2009 09:25 AM |
| Getting an error with OpenGL: collect2: ld returned 1 exit status | Lorgon Jortle | C++ Programming | 6 | 05-08-2009 08:18 PM |
| Didn't quite know where to post this.......compiler problem... | incognito | C++ Programming | 5 | 02-08-2003 07:42 PM |
| Interface Question | smog890 | C Programming | 11 | 06-03-2002 05:06 PM |
| I need help with passing pointers in function calls | vien_mti | C Programming | 3 | 04-24-2002 10:00 AM |