made ports reusable and added cannot connect to these ports in error class

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@453 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2013-02-06 17:36:03 +00:00
parent 1d03be832f
commit 9fe499e20c
4 changed files with 77 additions and 4 deletions

View File

@ -189,6 +189,15 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(ps),
}
// reuse port
int yes=1;
if (setsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
cerr << "setsockopt" << endl;
socketDescriptor=-1;
return;
}
if(bind(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
cerr << "Can not bind socket "<< endl;
socketDescriptor=-1;