khan@iuvax.cs.indiana.edu (04/10/89)
Can anyone tell me how to use bidirectional communication in UNIX tcp-ip, using STREAM sockets. I am trying to implement a CLIENT-SERVER model application. Here is what each of them successfully do: CLIENT: ... s = socket(AF_INT,SOCK_STREAM,0); if (s < 0) ... if (connect(s,(char *)&server, sizeof(server)) < 0) ... if (write(s,msg,strlen(msg)) < 0) ... SERVER: f = socket(AF_INET, SOCK_STREAM, 0); ... if (bind(f,(struct sockaddr *) &sin, sizeof(sin)) < 0) ... listen(f,5) for (;;) ... len = sizeof(from); g = accept(f,(struct sockaddr *)&from,&len); ... if ((rval = read(g,msg,1024)) < 0) ... The CLIENT succeeds in establishing a connection with the SERVER and sends it a message which the SERVER receives. Now the problem is that the server cannot send a message back to the CLIENT. I tried writing on the socket "g" on the SERVER side but it doesn't send the message. Could somebody tell me what I am doing wrong or what I am not doing. Thank you (you can send me mail if you like). ------------------ Iqbal Mustafa Khan ------------------ khan@iuvax.bacs.indiana.edu Computer Science Department Indiana University Bloomington, Indiana