Sponsored Content
Top Forums Programming how to solve error : Bind: Address Already in Use Post 302081771 by Hitori on Thursday 27th of July 2006 03:12:44 PM
Old 07-27-2006
Sometimes you try to bind() and have an error "Address already in use".
Someone is still handling the port. You can either wait for it to clear (a minute or so), or add code to your program allowing it to reuse the port:
Code:
int tr=1;

// kill "Address already in use" error message
if (setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&tr,sizeof(int)) == -1) {
    perror("setsockopt");
    exit(1);
}

 

10 More Discussions You Might Find Interesting

1. IP Networking

bind() error

Hello. I am havig problems with this program. It is a server supposed to get 2 integers from client, calculate a sum and send result back to client. I am getting a bind() error when attempting to execute it. Any help appreciated #include <stdio.h> #include <sys/types.h> #include... (2 Replies)
Discussion started by: Virtuosso
2 Replies

2. Programming

ldap bind error

hi Using C program i am trying to connect to ldap server i have used the method bind syntax : ldap_bind_s(ld,"cn=Manager,dc=example,dc=com","password") but it is not able to bind and giving error as error 2 :Historical protocol version required use ldapv3 instead do i need to add any... (2 Replies)
Discussion started by: mridula
2 Replies

3. Solaris

Where/What/Howto solve warning/error msg about Kernel patch level?

required Solaris 5.10 Kernel patch 137111-03 required Solaris 5.10 Fibre Channel Device Driver patch 125184-08 I want to know about the descriptions and what the patches will do. I searched www.sun.com (patches/updates) but don't see I am looking for. (1 Reply)
Discussion started by: Y4Net
1 Replies

4. Shell Programming and Scripting

Test argument error, unable to solve

Here is an awk statement i am using to sum a series of numbers.. awk -F"," '{ for (i=1; i<=NF ; ++i) sum += $i;} # if (i > max) max=i } END { s=""; for (i=1; i<=max; ++i) { printf "%s%s", s, sum; s=","; } printf "\n" }' filename.csv It works fine for the summing part. But since my series... (19 Replies)
Discussion started by: pravsripad
19 Replies

5. Solaris

bind error

Hi, When I use the ldapadd command I get this error. ldap_simple_bind: Conidentiality required ldap_simple_bind: additional info: confidentiality required I was able to use this command and the ldapsearch command yesterday just fine. I think I may have made a change to a file, but I don't... (2 Replies)
Discussion started by: bitlord
2 Replies

6. UNIX for Dummies Questions & Answers

i dont know how to solve this error

can while do make aloop as do while in c language ? (1 Reply)
Discussion started by: teefa
1 Replies

7. Shell Programming and Scripting

What is this error log = hda: irq timeout: error=0x00 and how to solve?

what is this error log = hda: irq timeout: error=0x00 and how to solve? every day upon checking the logs i see this error. hda: irq timeout: error=0x00 hda: irq timeout: error=0x00 hda: irq timeout: error=0x00 hda: irq timeout: error=0x00 hw_client: segfault at 0000000000000046 rip... (3 Replies)
Discussion started by: avtalan
3 Replies

8. Shell Programming and Scripting

How to solve awk: line 1: runaway string constant error?

Hi All ! I am just trying to print bash variable in awk statement as string here is my script n=1 for file in `ls *.tk |sort -t"-" -k2n,2`; do ak=`(awk 'FNR=='$n'{print $0}' res.dat)` awk '{print "'$ak'",$0}' OFS="\t" $file n=$((n+1)) unset ak doneI am getting following error awk:... (7 Replies)
Discussion started by: Akshay Hegde
7 Replies

9. Red Hat

Bind (DNS) error on EL 6.4

Gurus I have configured bind 9 on Red hat EL 6.4, it can resolve from hostname i.e from domain name (like cnn.com, bbc.com)but through IP its shows following error. Need your expert opinion to solve it. error 84.23.97.31 Server: 192.168.31.24 Address: 192.168.31.24#53 ** server can't... (1 Reply)
Discussion started by: smazshah
1 Replies

10. Shell Programming and Scripting

How to solve ambigious redirect error?

hi all, i had the below script filename = /osa/data1/output.txt printf '%27s%53s\n' ' CURRENT DATE' 26-08-2014 >> $filename iam getting the ambigiuos redirect error in the 2nd line of the code...please guide me regards, vasa saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies
setsockopt(3XNET)				   X/Open Networking Services Library Functions 				 setsockopt(3XNET)

NAME
setsockopt - set the socket options SYNOPSIS
cc [ flag... ] file... -lxnet [ library... ] #include <sys/socket.h> int setsockopt(int socket, int level, int option_name, const void*option_value, socklen_t option_len); DESCRIPTION
The setsockopt() function sets the option specified by the option_name argument, at the protocol level specified by the level argument, to the value pointed to by the option_value argument for the socket associated with the file descriptor specified by the socket argument. The level argument specifies the protocol level at which the option resides. To set options at the socket level, specify the level argu- ment as SOL_SOCKET. To set options at other levels, supply the appropriate protocol number for the protocol controlling the option. For example, to indicate that an option will be interpreted by the TCP (Transport Control Protocol), set level to the protocol number of TCP, as defined in the<netinet/in.h> header, or as determined by using getprotobyname(3XNET). The option_name argument specifies a single option to set. The option_name argument and any specified options are passed uninterpreted to the appropriate protocol module for interpretations. The <sys/socket.h> header defines the socket level options. The options are as fol- low SO_DEBUG Turns on recording of debugging information. This option enables or disables debugging in the underlying protocol modules. This option takes an int value. This is a boolean option. SO_BROADCAST Permits sending of broadcast messages, if this is supported by the protocol. This option takes an int value. This is a boolean option. SO_REUSEADDR Specifies that the rules used in validating addresses supplied to bind(3XNET) should allow reuse of local addresses, if this is supported by the protocol. This option takes an int value. This is a boolean option. SO_KEEPALIVE Keeps connections active by enabling the periodic transmission of messages, if this is supported by the protocol. This option takes an int value. If the connected socket fails to respond to these messages, the connection is broken and threads writing to that socket are notified with a SIGPIPE signal. This is a boolean option. SO_LINGER Lingers on a close(2) if data is present. This option controls the action taken when unsent messages queue on a socket and close(2) is performed. If SO_LINGER is set, the system blocks the process during close(2) until it can transmit the data or until the time expires. If SO_LINGER is not specified, and close(2) is issued, the system handles the call in a way that allows the process to continue as quickly as possible. This option takes a linger structure, as defined in the <sys/socket.h> header, to specify the state of the option and linger interval. SO_OOBINLINE Leaves received out-of-band data (data marked urgent) in line. This option takes an int value. This is a boolean option. SO_SNDBUF Sets send buffer size. This option takes an int value. SO_RCVBUF Sets receive buffer size. This option takes an int value. SO_DONTROUTE Requests that outgoing messages bypass the standard routing facilities. The destination must be on a directly-con- nected network, and messages are directed to the appropriate network interface according to the destination address. The effect, if any, of this option depends on what protocol is in use. This option takes an int value. This is a boolean option. For boolean options, 0 indicates that the option is disabled and 1 indicates that the option is enabled. Options at other protocol levels vary in format and name. USAGE
The setsockopt() function provides an application program with the means to control socket behavior. An application program can use set- sockopt() to allocate buffer space, control timeouts, or permit socket data broadcasts. The <sys/socket.h> header defines the socket-level options available to setsockopt(). Options may exist at multiple protocol levels. The SO_ options are always present at the uppermost socket level. RETURN VALUES
Upon successful completion, setsockopt() returns 0. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The setsockopt() function will fail if: EBADF The socket argument is not a valid file descriptor. EDOM The send and receive timeout values are too big to fit into the timeout fields in the socket structure. EFAULT The option_value parameter can not be accessed or written. EINVAL The specified option is invalid at the specified socket level or the socket has been shut down. EISCONN The socket is already connected, and a specified option can not be set while the socket is connected. ENOPROTOOPT The option is not supported by the protocol. ENOTSOCK The socket argument does not refer to a socket. The setsockopt() function may fail if: ENOMEM There was insufficient memory available for the operation to complete. ENOBUFS Insufficient resources are available in the system to complete the call. ENOSR There were insufficient STREAMS resources available for the operation to complete. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
bind(3XNET), endprotoent(3XNET), getsockopt(3XNET), socket(3XNET), attributes(5), standards(5) SunOS 5.10 1 Nov 2003 setsockopt(3XNET)
All times are GMT -4. The time now is 02:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy