Article 4XA3X Howe implement while loop for send and recive message in c

Howe implement while loop for send and recive message in c

by
end
from LinuxQuestions.org on (#4XA3X)
hi

howe in while loop make comunication boath side automatic i need press enter or send message to recive message. i test it with netcat nc and canot recive message before i send. howe to write while loop.

Code:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include<arpa/inet.h>

int main(int argc , char *argv[] )
{
int sockett;
struct sockaddr_in server;
char buffer[1024];
char bufferr[1024];
int rcv;

sockett=socket(AF_INET, SOCK_STREAM,0);

server.sin_family=AF_INET;
server.sin_port= htons(80);
server.sin_addr.s_addr =inet_addr(argv[1]);

int ret =-1;
ret = connect(sockett, (struct sockaddr *)&server, sizeof(struct sockaddr_in));

while(1 )
{

if( recv(sockett,buffer,1024,0) >0 )
printf("%s",buffer);

if (send(sockett,bufferr,strlen(bufferr),0) >0 )
scanf("%s",bufferr,1024);

}

}latest?d=yIl2AUoC8zA latest?i=PxurG_T6QLg:uK1057f0r9k:F7zBnMy latest?i=PxurG_T6QLg:uK1057f0r9k:V_sGLiP latest?d=qj6IDK7rITs latest?i=PxurG_T6QLg:uK1057f0r9k:gIN9vFwPxurG_T6QLg
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments