Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie: cannot continue send() or recv()

2 views
Skip to first unread message

nfigl...@gmail.com

unread,
Feb 11, 2008, 10:55:26 AM2/11/08
to
Hello!

I'm very new on C and Winsock programming (i did some VB with winsock
control).
I've started with a little app. It works pretty well using an ECHO
server: i send a message, and i receive the same. Cool.
But, when i connect with a SMTP, POP or any other service, i receive a
first message, and then it hangs up.

My code:

/******* part: LOOP */

do{
sendm(recvskt); rcv_b =
recvm(recvskt);
}while(rcv_b != 0);

/********** end */

And the send and receive functions (which are properly declared):

/********* functions */

int sendm(int socket){
scanf("%s", &request);
int snd_b = strlen(request);
snd_b = send(socket, (char *)request, snd_b, 0);
return snd_b;

}

int recvm(int socket){
rcv_b=recv(socket, (char *)buffer, BUF, 0);
buffer[rcv_b] = NULL;
printf("\nRcv. Bytes: %d\n\n", rcv_b);
strcat(temp, buffer);
printf("%s\r\n", buffer);
return rcv_b;

}

/*********** end */+

Please help. I do not understand why with an ECHO server things works
and not the same with other services. I just want to write a simple
"telnet" or tcp chat app.

Thanks
Nicolas

0 new messages