LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-13-2008, 08:36 AM   #1
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Rep: Reputation: 0
Lightbulb linux:socket(address already in use)


hi,
when i run my socket program i ve received the error "address already in use". so i tried the following
if ( setsockopt(s, SOL_SOCKET, SO_REUSEADRR, 1, sizeof(int)))
error ("setsockopt failed");

now i ve received the error "
SO_REUSEADRRâ undeclared (first use in this function)"

how can solve my problem?
 
Old 05-13-2008, 08:48 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Try this
Code:
int optval;
optval = 1;
if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval)))
 
Old 05-13-2008, 09:17 AM   #3
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
hi,
i did the correction. Now again i got the same error "address already in use".what to do?
 
Old 05-13-2008, 09:19 AM   #4
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
What port are u trying to bind to ?
 
Old 05-14-2008, 06:09 AM   #5
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
In unix domain socket there is no port. im giving the same path(from pwd-command)for both client and server.
 
Old 05-14-2008, 06:36 AM   #6
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Okay if it is a domain socket remove the socket file, it is the one blocking the bind.
 
Old 05-15-2008, 12:53 AM   #7
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
i ve deleted the file but till getting the same error. how to correct it?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can not bind socket to address terrormaniak Linux - Server 1 09-14-2007 02:16 PM
can not bind socket to address terrormaniak Linux - Software 0 09-12-2007 04:00 PM
Could not get interface address for socket! karlilinux Linux - Networking 2 01-12-2006 05:11 AM
cannot bind to socket: address already in use exfacior Linux - Wireless Networking 0 09-27-2004 01:34 PM


All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration