socket data problem

Network related discussions (including general TCP/IP stuff, routing, etc).

socket data problem

Postby Poldan » 10 May 2010, 08:24

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?
Poldan
Junior Member
 
Posts: 2
Joined: 10 May 2010, 06:19

Postby expl » 10 May 2010, 12:09

You might want to post full source of your app.
User avatar
expl
Member
 
Posts: 664
Joined: 30 Oct 2009, 23:54
Location: In your shell, stealing your cookies.

Postby Poldan » 10 May 2010, 12:48

server:
Code: Select all
....
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: Select all
.....
socket($socket, PF_INET, SOCK_STREAM, $prot);
connect($socket, $addr);
fcntl $socket, &F_SETFL, O_NONBLOCK;
$socket->autoflush(1);
......

print $socket $line;
Poldan
Junior Member
 
Posts: 2
Joined: 10 May 2010, 06:19


Return to Networking

Who is online

Users browsing this forum: No registered users and 0 guests