socket data problem

Can anyone help me with some problem? Have FreeBSD 7.2. When print in perl to the socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp') ) some times have strange problem. For example - i send to strings to the server - "string1\n" and "STRING2\n". But server receives mixed or broken lines. Something like that "stSTRring1ING2". It's happening on heavy traffic. Why this happening and what can i do to to avoid this errors?
 
server:
Code:
....
socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp') ) ;
setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) ;
bind(SERVER, sockaddr_in($port, inet_aton($interface))) ;
listen(SERVER,$mconn);
                                                       
while (1) {
        sleep 1;
        accept(CLIENT,SERVER)

......
client:
Code:
.....
socket($socket, PF_INET, SOCK_STREAM, $prot);
connect($socket, $addr);
fcntl $socket, &F_SETFL, O_NONBLOCK;
$socket->autoflush(1);
......

print $socket $line;
 
Back
Top