SCTP Discussions

Text archives Help


[SCTP-Discussion] Regarding SO_REUSEADDR option in socketsapi


Chronological Thread 
  • From: rohit agrawal <agrawal_rohit1 AT yahoo.co.in>
  • To: sctp <discussion AT sctp.de>
  • Subject: [SCTP-Discussion] Regarding SO_REUSEADDR option in socketsapi
  • Date: Mon Apr 24 14:12: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=XDswEr/XIMkBig2m60+rVDRk188s74fMo0yzdLzsB+Km9yNSb9gHmWQP8wXnkWLCv/X/jxyKMtkHQzaJwHQtFYodnKFdH11mVjNQblorkJqr4RFaIS3zV+20R1mViQoUyXcj9EHuPs9I1twK3Fjf1ySslLZCPXgb7j35sMIJCc8= ;
  • 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.


Archive powered by MHonArc 2.6.19+.

Top of page