Sockets for clients Flashcards
What are connections between?
client and the server
what is the server?
software actively listening for a connection
What is the client?
software that connects to a server
Do we need both?
yes we need both to form an active connection
benefits of TCP connections?
reliable and steam oriented connection
What do machines need to be doing?
1 needs to be listening for connection and the other needs to connect to that open port
What is the connection type?
Bi-directional
What does a protocol describe?
how the communication should happen
order bits are sent in
what individual bits mean
What is the Http protocol?
send a request and get a repsonse
simple requests are easy
What is the de facto API for TCP/IP?
Berkeley sockets
What do sockets API use?
recv(), send(), close()
do we open a connection?
no rather we create socket using socket()
which is one end of our connection and theres another socket at the other end
What does client need?
create a socket with socket()
connect to a server using connect()
transfer data using send()/recv()
close the connection using close()
How do we create socket?
use socket() function
tell what domain we need socket in
type of connection we want
the protocol
returns the file descriptor for created socket or -1 if errors
How do we connect?
use connect() function
socket needs to be connected to other end of connection
need address of the end point
ip address of machine and port to connect to
use struct sockaddr_in to contain details