Sponge
CS144's user-space TCP library
Functions | Variables
socket_example_2.cc File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

sock1 bind (Address("127.0.0.1", portnum))
 
sock1 close ()
 
sock2 connect (Address("127.0.0.1", portnum))
 
 if (recvd !="hi there"||recvd2 !="hi yourself")
 
sock1 listen (1)
 
sock3 shutdown (SHUT_RDWR)
 
sock3 write ("hi there")
 
sock2 write ("hi yourself")
 

Variables

const uint16_t portnum = ((std::random_device()()) % 50000) + 1025
 
auto recvd = sock2.read()
 
auto recvd2 = sock3.read()
 
TCPSocket sock1
 
TCPSocket sock2
 
auto sock3 = sock1.accept()
 

Function Documentation

◆ bind()

sock1 bind ( Address("127.0.0.1", portnum )

◆ close()

sock2 close ( )

◆ connect()

sock2 connect ( Address("127.0.0.1", portnum )

◆ if()

if ( recvd = "hi there" || recvd2 != "hi yourself")

Definition at line 24 of file socket_example_2.cc.

◆ listen()

sock1 listen ( )

◆ shutdown()

sock3 shutdown ( SHUT_RDWR  )

◆ write() [1/2]

sock3 write ( "hi there"  )

◆ write() [2/2]

sock2 write ( "hi yourself"  )

Variable Documentation

◆ portnum

const uint16_t portnum = ((std::random_device()()) % 50000) + 1025

Definition at line 1 of file socket_example_2.cc.

◆ recvd

auto recvd = sock2.read()

Definition at line 16 of file socket_example_2.cc.

◆ recvd2

auto recvd2 = sock3.read()

Definition at line 19 of file socket_example_2.cc.

◆ sock1

TCPSocket sock1

Definition at line 4 of file socket_example_2.cc.

◆ sock2

TCPSocket sock2

Definition at line 9 of file socket_example_2.cc.

◆ sock3

auto sock3 = sock1.accept()

Definition at line 13 of file socket_example_2.cc.