SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] Regarding SO_REUSEADDR option in socketapi


Chronological Thread 
  • From: Michael Tuexen <Michael.Tuexen AT micmac.franken.de>
  • To: Thomas Dreibholz <dreibh AT iem.uni-due.de>
  • Cc: sctp <discussion AT sctp.de>, rohit agrawal <agrawal_rohit1 AT yahoo.co.in>
  • Subject: Re: [SCTP-Discussion] Regarding SO_REUSEADDR option in socketapi
  • Date: Mon Apr 24 16:42:04 2006
  • List-id: SCTP Discussions <discussion.sctp.de>

Thomas,

is this functionality implemented? I think it might be difficult and might
therefore not be implemented...

Best regards
Michael

On Apr 24, 2006, at 2:04 PM, rohit agrawal wrote:

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.





Archive powered by MHonArc 2.6.19+.

Top of page