![]() ![]() The concept of “connections” apply to SOCK_STREAM/TCP type of sockets. Lets do the next thing, sending some data to the remote server. Try connecting to a port different from port 80 and you should not be able to connect which indicates that the port is not open for connection. If you run the program it should show Connected. First is create a sockaddr_in structure with proper values filled in. To connect to a remote server we need to do a couple of things. ![]() So we need 2 things, IP address and port number to connect to. We connect to a remote server on a certain port number. In this tutorial we shall stick to SOCK_STREAM or TCP sockets. This type of socket is non-connection socket. We can connect to Īpart from SOCK_STREAM type of sockets there is another type called SOCK_DGRAM which indicates the UDP protocol. ![]() But what next ? Next we shall try to connect to some server using this socket. Ok, so you have created a socket successfully. It would be a good idea to read some documentation here Type : SOCK_STREAM (this means connection oriented TCP protocol) The above code will create a socket of :Īddress Family : AF_INET (this is IP version 4) Function socket() creates a socket and returns a socket descriptor which can be used in other network commands. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |