|
Hi!program.
i have a problem with my rpg server program.
i am followig the code from Scott Klement to wite a simple server
used
i create a socket, bind it, listen and accept a connection. the i send a
small string and receive a small string.
after that i close the accepted socket and the original server socket
for bind.not
But sometimes the connection stay open and the close of the socket is
successfull. i cannot restart the serer because the socket is alreadythe
bound.
when i do netstat *cnn i see the connection is in state time_wait and
listening socket is not closed.the
both close calls return withaout an error so why does the os not close
sockets?
Grettings,
Fanz
Here is the Code:
message = 'TEST';
address = *allx'00';
address.sin_family = AF_INET;
address.sin_port = 9001;
address.sin_addr.s_addr = INADDR_ANY;
connection = socket(AF_INET:SOCK_STREAM:IPPROTO_TCP);
if bind(connection:%addr(address):%size(address) ) = -1;
rc = close(connection);
return;
endif;
if listen(connection:1 ) < 0;
rc = close(connection);
return;
endif;
newsock = accept(connection:p_address2:len);
len = send(newsock:%addr(message:*data):%size(message):0);
len = recv(newsock:%addr(ret):%size(ret):0);
rc = close(newsock);
rc1 = close(connection);
printf('message: %s %s %s <<%s>>' + x'25' : %char(rc) : %char(rc1):
%char(len): ret);
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.