![]() |
| | #1 |
| Registered User Join Date: Jun 2005 Location: Philadelphia
Posts: 16
| Code: while(true)
{
while((recv(Socket, buffer, strlen(buffer), 0) != 0) ||
(recv(Socket, buffer, strlen(buffer), 0) != -1))
{
cout<<buffer;
break;
}
memset(buffer, 0, strlen(buffer));
cin>>cintext;
strcpy(texttosend, "PRIVMSG #blahhh :");
strcat(texttosend, cintext);
strcat(texttosend, "\r\n");
send(Socket, texttosend, strlen(texttosend), 0);
memset(cintext, 0, 255); memset(texttosend, 0, 255);
}
|
| RedZone is offline | |
| | #2 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,662
| > recv(Socket, buffer, strlen(buffer), 0) If you've cleared the buffer before, then strlen is going to return 0. Use sizeof if your buffer is an array (not a pointer). Eg. Code: while ( (n=recv(Socket, buffer, sizeof(buffer), 0)) > 0 ) {
// Note that recv DOESN'T append a \0, so use 'n' to determine
// what to do
}
if ( n == 0 ) {
// closed
}
if ( n == -1 ) {
// error
}
|
| Salem is offline | |
| | #3 |
| Registered User Join Date: Jun 2005 Location: Philadelphia
Posts: 16
| Thanks for the help, fixed everything and it works just as I wanted it to. |
| RedZone is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Spy++ view messages posted/sent to a control, or from it? | hanhao | Windows Programming | 2 | 06-24-2007 11:07 PM |
| IRC, reading the stream | Iyouboushi | C# Programming | 6 | 08-03-2006 05:34 PM |
| Sending windows messages | Ideswa | Windows Programming | 2 | 03-02-2006 01:27 PM |
| Some help needed with IRC | SaintK | C++ Programming | 2 | 04-04-2004 07:27 AM |