SOCKET_CONNECT(3) 1 SOCKET_CONNECT(3)socket_connect - Initiates a connection on a socketSYNOPSIS
bool socket_connect (resource $socket, string $address, [int $port])
DESCRIPTION
Initiate a connection to $address using the socket resource $socket, which must be a valid socket resource created with socket_create(3).
PARAMETERS
o $socket
-
o $address
- The $address parameter is either an IPv4 address in dotted-quad notation (e.g. 127.0.0.1) if $socket is AF_INET, a valid IPv6
address (e.g. ::1) if IPv6 support is enabled and $socket is AF_INET6 or the pathname of a Unix domain socket, if the socket fam-
ily is AF_UNIX.
o $port
- The $port parameter is only used and is mandatory when connecting to an AF_INET or an AF_INET6 socket, and designates the port
on the remote host to which a connection should be made.
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.
Note
If the socket is non-blocking then this function returns FALSE with an error Operation now in progress.
SEE ALSO socket_bind(3), socket_listen(3), socket_create(3), socket_last_error(3), socket_strerror(3).
PHP Documentation Group SOCKET_CONNECT(3)
Check Out this Related Man Page
SOCKET_GETSOCKNAME(3) 1 SOCKET_GETSOCKNAME(3)socket_getsockname - Queries the local side of the given socket which may either result in host/port or in a Unix filesystem path, dependent on
its typeSYNOPSIS
bool socket_getsockname (resource $socket, string &$addr, [int &$port])
DESCRIPTION
Note
socket_getsockname(3) should not be used with AF_UNIX sockets created with socket_connect(3). Only sockets created with
socket_accept(3) or a primary server socket following a call to socket_bind(3) will return meaningful values.
PARAMETERS
o $socket
- A valid socket resource created with socket_create(3) or socket_accept(3).
o $addr
- If the given socket is of type AF_INET or AF_INET6, socket_getsockname(3) will return the local IP address in appropriate nota-
tion (e.g. 127.0.0.1 or fe80::1) in the $address parameter and, if the optional $port parameter is present, also the associated
port. If the given socket is of type AF_UNIX, socket_getsockname(3) will return the Unix filesystem path (e.g. /var/run/dae-
mon.sock) in the $address parameter.
o $port
- If provided, this will hold the associated port.
RETURN VALUES
Returns TRUE on success or FALSE on failure. socket_getsockname(3) may also return FALSE if the socket type is not any of AF_INET,
AF_INET6, or AF_UNIX, in which case the last socket error code is not updated.
SEE ALSO socket_getpeername(3), socket_last_error(3), socket_strerror(3).
PHP Documentation Group SOCKET_GETSOCKNAME(3)
Could anyone tell me please:
-what the socket number of a network computer is?
-How it is related to the IP address?
-And how can I obtain this information from my work station?
:D (2 Replies)
Excuse me . I'm a beginner . In windows , MFC can be used , but how to do in Unix ? And does unix support c++like VC++ ? How can I get developing tools in Unix ? (7 Replies)
my system is a stand alone system... i want to try doing socket porgramming..ihave heard that this is usually done during testing...
how can i do that....? (6 Replies)
Hi all,
Situation is as below.
I would get an IP address and port from eithe r a file or command line. It probably would be as char * or string. So was wondering how I could accept this and increment the last octets?
Incrementing the port is fine. I could get that into an integer by atoi()... (8 Replies)
hello,
I am doing Socket programming..
when I am establishing a socket connection using TCP protocol ...I am getting
Error :: No route to host. at the client side during connect() call...........that it is returning -1.
So I thing problem lies here......but what to do now...
So for just... (6 Replies)
When i put the target IP as 127.0.1.1, the program is working fine, can catch blocked & open ports. But when i try to scan remotely, i get connection timed out! Can you tell me why? :(
Here is my code - Look at between where i put astriks - at the bottom:
#include<iostream>... (3 Replies)
hi all,
i meet a problem when opening a socket, is that when the remote host not available or its port hanged ,my program still suspending untill i cancel the operation...
but when the host is ok ,my program work ok.
i handled in my code all these exceptions ,but my problem is when the host is... (6 Replies)
I have written a flash socket security file server in PHP. The basic idea is that when Flash Player connects via socket to a server, the first thing it does is connect to port 843 and send a request for a 'socket policy file' by sending the string <policy-file-request/>.
The problem I have is... (5 Replies)
I am using c to send data to a socket with the following commands:
socket = socket(AF_INET, SOCK_STREAM, ptrp->p_proto);
ioctl(socket, FIONBIO, (char *)&on);
connect(socket)
send(socket,data)
shutdown(socket, SHUT_WR);
recv(socket) //ready last of data waiting on the port
//note this is... (3 Replies)
hi all,
Im using a tcp socket for communication. After all the communications I close the socket and bind another socket to the same port. But it shows bind error. I see it is due to the port no being used immediately. But i am closing the first socket before the binding the second one to the... (9 Replies)
Hai every one ,,,
I am runinng one tcp socket in non-blocking mode. In the connect state(operation in progress) if the server is not running ,client socket select will give success.
FD_ISSET(socketfd,&wfd) will give me succes always and am getting wfd value as 16. I tried with blocking... (6 Replies)
Hello,
Please help me in getting the process id and the port number from the socket
netstat -Aan|grep -i closed
f100050010b133b8 tcp 0 0 *.* *.* CLOSED
f1000500119b53b8 tcp4 0 0 *.* *.* ... (3 Replies)