If this question is in the wrong group, then
let me know where it should be posted.
I am communicating between 2 SGI's using
sockfd = socket(AF_INET, SOCK_STREAM, 0)
My main question is why is the communications so slow?
Especially in the following paradigm.
First I create the sockets and make a connection
all of which is done successfully.
I then proceed into a while loop
while ( 1 )
{
...
ClientOrServerRW();
...
if your process is the server then:Quote:}
ClientOrServerRW() = ServerWriteRead()
whose code is:
ServerWriteRead()
{
write( sockfd, &data_set1, datasize );
read( sockfd, &data_set2, datasize );
if your process is the client then:Quote:}
ClientOrServerRW() = ClientReadWrite()
whose code is:
ClientReadWrite()
{
read( sockfd, &data_set2, datasize );
write( sockfd, &data_set1, datasize );
This process seems to work somewhat well,Quote:}
the communication speed is acceptable, not preferable.
But when I add one more write to ServerWriteRead()
and one more read to ClientReadWrite(),
the communications almost comes to a complete hault.
Why?
What is even more strange is that when I bring this
up in the de* it seems most of the time is spent
on the first read ( on the Server side ).
Why?
I tried a non-blocking read/write method but this didn't
seem to help. To set non-blocking, I made this call:
ioctl ( sockfd, O_NONBLOCK, 1 );
Would this be the correct way to set non-blocking?
Please feel free to attack the method of communicating
if it is inefficient. I would like to know.
Keep in mind that the goal I am trying to achieve
is constant, up-to-date data between the Client and Server.
(Example: (x,y) coordinate pairs that are on the Client side
in which the Server should know and vice-versa.)
Any help is greatly appreciated,
-DaveS
===========================================================================
| Product Development -- Feature Based | 513-576-2601 (Voice) |
| Applications | 513-576-???? (FAX) |
| Structural Dynamics Research Corporation | |
| 2000 Eastman Drive | ? |
| Milford, OH 45150 | |