Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

socket_listen(3) [debian man page]

socket_listen(3)					     Library Functions Manual						  socket_listen(3)

NAME
socket_listen - attempt to make a TCP connection SYNTAX
#include <socket.h> int socket_listen(int s,int n); DESCRIPTION
socket_listen prepares TCP socket s to accept TCP connections. It allows a backlog of approximately n TCP SYNs. (On systems supporting SYN cookies, the backlog is irrelevant.) Normally socket_listen returns 0. If anything goes wrong, socket_listen returns -1, setting errno appropriately. EXAMPLE
#include <socket.h> int s; char ip[16]; uint16 p; if ((s=socket_tcp6())==-1) strerr_die2sys(111,FATAL,"unable to create TCP socket: "); if (socket_bind6_reuse(s,(char *)V6any,8002,0) == -1) strerr_die2sys(111,FATAL,"unable to bind: "); if (socket_listen(s,1) == -1) strerr_die2sys(111,FATAL,"unable to listen: "); SEE ALSO
socket_connect4(3), socket_connect6(3) socket_listen(3)

Check Out this Related Man Page

SOCKET_BIND(3)								 1							    SOCKET_BIND(3)

socket_bind - Binds a name to a socket

SYNOPSIS
bool socket_bind (resource $socket, string $address, [int $port]) DESCRIPTION
Binds the name given in $address to the socket described by $socket. This has to be done before a connection is be established using socket_connect(3) or socket_listen(3). PARAMETERS
o $socket - A valid socket resource created with socket_create(3). o $address - If the socket is of the AF_INET family, the $address is an IP in dotted-quad notation (e.g. 127.0.0.1). If the socket is of the AF_UNIX family, the $address is the path of a Unix-domain socket (e.g. /tmp/my.sock). o $port (Optional) - The $port parameter is only used when binding an AF_INET socket, and designates the port on which to listen for connections. RETURN VALUES
Returns TRUE on success or FALSE on failure. The error code can be retrieved with socket_last_error(3). This code may be passed to socket_strerror(3) to get a textual explanation of the error. EXAMPLES
Example #1 Using socket_bind(3) to set the source address <?php // Create a new socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); // An example list of IP addresses owned by the computer $sourceips['kevin'] = '127.0.0.1'; $sourceips['madcoder'] = '127.0.0.2'; // Bind the source address socket_bind($sock, $sourceips['madcoder']); // Connect to destination address socket_connect($sock, '127.0.0.1', 80); // Write $request = 'GET / HTTP/1.1' . " " . 'Host: example.com' . " "; socket_write($sock, $request); // Close socket_close($sock); ?> NOTES
Note This function must be used on the socket before socket_connect(3). Note Windows 9x/ME compatibility note: socket_last_error(3) may return an invalid error code if trying to bind the socket to a wrong address that does not belong to your machine. SEE ALSO
socket_connect(3), socket_listen(3), socket_create(3), socket_last_error(3), socket_strerror(3). PHP Documentation Group SOCKET_BIND(3)
Man Page

12 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

connecting to windows from unix

how to connect to windows from unix??? (7 Replies)
Discussion started by: hemant30
7 Replies

2. UNIX for Dummies Questions & Answers

Help please

The email database server is designed to accept multiple incoming requests via a socket in order to locate a specific message and return it to the client email browser (such as Outlook Express). Why the server may launch a thread to handle each incoming request. What benefit does the threading... (1 Reply)
Discussion started by: bole
1 Replies

3. Programming

help me out with my threaded c++ mudbase - c++, pthread_cond_wait

hello, in my free time i am writing on a c++ mud codebase, a while ago i decided that i would move to pthreads, so i could make use of smp. now i have a problem which i just cant fix - for weeks now. i have a main thread which spawns my threads, as soon as spawned they get a pthread_cond_wait, so... (4 Replies)
Discussion started by: sonicx
4 Replies

4. IP Networking

port 143 doesn't work

Hi folks, Postfix Dovecot-imap 1.0 port 143 not working. $ telnet localhost 143 Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. * OK Dovecot ready. 1 login satimis mypassword 1 NO Authentication failed. * BYE Disconnected for inactivity.... (1 Reply)
Discussion started by: satimis
1 Replies

5. UNIX for Advanced & Expert Users

Server Programming to keep on looking for client connection

Hi I wrote a server Program in C, Here it is, this is a just socket creation alone, bool myclass::CreateSocket() { struct sockaddr_in sockaddr_in; sockaddr_in.sin_family = AF_INET; sockaddr_in.sin_port = 1100; sockaddr_in.sin_addr.s_addr = INADDR_ANY; ... (4 Replies)
Discussion started by: vij_krr
4 Replies

6. Solaris

Killing a thread having a listener socket

Hi All I have a separate thread ListenerThread having a socket listening to info broadcasted by some remote server. This is created in my main thread. Because of requirements, once the separate thread is started I need to avoid any blocking function on the main thread. Once it comes to the... (2 Replies)
Discussion started by: manustone
2 Replies

7. Emergency UNIX and Linux Support

Perl script logging via Shell script

Hello I wrote a nice Perl script that is intended to find and copy some files when getting a TERM signal. Now I wanted to make a shell script that starts/restarts the Perl script if it crashes/ends because of errors and make a log of all output the Perl Script gives. The problem is that it won't... (11 Replies)
Discussion started by: al0x
11 Replies

8. Red Hat

Help requested with Dovecot configuration to work with Posfix and MySQL

Hi guys, I want to convert this Dovecot configuration file for Dovecot 1.x to a dovecot file for Dovecot 2.x ================== /etc/dovecot.conf ================== protocols = imap imaps pop3 pop3s log_timestamp = "%Y-%m-%d %H:%M:%S " mail_location = maildir:/home/vmail/%d/%n/Maildir ... (0 Replies)
Discussion started by: redhat19
0 Replies

9. Linux

bash:umount/: no such file or directory

I am trying to connect two system (let's say for time being) together such that it supports clustering. for this I got the following packages: # sudo apt-get install pacemaker sysv-rc-conf glusterfs-server glusterfs-examples glusterfs-client chkconfig nmap ntp Next, I did... (0 Replies)
Discussion started by: dr_mabuse
0 Replies

10. IP Networking

Totally stucked in ssh port forwarding

Hello my friends , i am totally stuck in ssh port forwarding topic i had learn iptables and other networking topic without any problem but ssh port forwarding is headache 1. local port = what is this ? is this incoming traffic or outgoing traffic 2. remote port = same as above 3. dynamic... (2 Replies)
Discussion started by: rink
2 Replies

11. Proxy Server

WebSocket over SSH tunnel - is it possible?

Hello, I have a video streaming application that utilizes a WebSocket for the server <-> client communication. My goal is to make the video streaming service available over the internet in the cases where neither the server nor client have public IPs. One way to do this is over a VPN... (8 Replies)
Discussion started by: Vladislav
8 Replies

12. Shell Programming and Scripting

Need Script to check the FTP connection

Hi, I need a script which check the FTP connections, if its working fine then no issue. Incase not working fine then Trigger the mail. Please help on this. Thanks (4 Replies)
Discussion started by: Keshav Kalra
4 Replies