- From: rohit agrawal <agrawal_rohit1 AT yahoo.co.in>
- To: sctp <discussion AT sctp.de>
- Subject: [SCTP-Discussion] Regarding SO_REUSEADDR option in socketapi
- Date: Mon Apr 24 14:52:01 2006
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=3f+AJfnOrA/EzsgTchUcajWbp09l2lFrqHOZNhfxHsE4YfZ8dzJAMdg5a3sW/ltqj9bQ1mcCe7WYpmW71IDR59SPvmbpJsweJLApIv1duLYjOnbzN9ZbCMb5TyN3r8bhsJs6paYhk/MY6pPzc0z0if1zytq0YRAzSeE1Reur+GI= ;
- List-id: SCTP Discussions <discussion.sctp.de>
Hi,
I tried to use the function setSoReuseAddress() function present in cppsocketapi directory but the result is "SCTP bind error: Address already in use". I also tried to set the option SO_REUSEADDR through socketapi (C functions) using function ext_setsockopt, but there too it is giving me the same result.
Am i using the function in a wrong way. If so please tell me the correct way to resue this Socket option.
Below is the sample program
#include <cstdio>
#include <iostream.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/uio.h>
#include "tdsystem.h"
#include "thread.h"
#include "tdsocket.h"
#include "tdmessage.h"
#include "randomizer.h"
#include "breakdetector.h"
#include "ext_socket.h"
#include
<signal.h>
int main(int argc,char *argv[])
{
struct sockaddr_in servaddr;
bool boolres=false;
cout<<"Initially boolres variable is: "<<boolres;
// SCTP handling starts
Socket clientSocket1(Socket::IP,Socket::Stream,Socket::SCTP);
cout<<"\nSocket Initialized successfully--1";
boolres = clientSocket1.setSoReuseAddress(true);
printf("\nThe result of setsoreuse-1 is %d",boolres);
//Binding the SCTP socket
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(atoi(argv[1]));
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
InternetAddress address1((struct sockaddr *)&servaddr,sizeof(servaddr));
if (clientSocket1.bind(address1)== false)
{
perror("\nSCTP bind
error");
exit(1);
}
printf("\nSocket bounded successfully--1");
Socket clientSocket2(Socket::IP,Socket::Stream,Socket::SCTP);
cout<<"\nSocket Initialized successfully--2";
if (clientSocket2.bind(address1) == false)
{
perror("\nSCTP bind error");
exit(1);
}
printf("\n Socket bounded successfully--2");
printf("\n Socket bounded successfully--2");
}
I will be thankful for your response.
Thanks and regards
Rohit Agrawal
Jiyo cricket on
Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
- [SCTP-Discussion] Regarding SO_REUSEADDR option in socketapi, rohit agrawal, 04/24/2006
Archive powered by MHonArc 2.6.19+.