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 socketSYNOPSIS
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)