I presume you are using INET framework for OMNeT++ (see http://inet.omnetpp.org/ ). In this case, you shall read through TCPSocket (http://inet.omnetpp.org/doc/INET/doxy/class_t_c_p_socket.html) and UDPSocket (http://inet.omnetpp.org/doc/INET/doxy/class_u_d_p_socket.html) classes and brief usage provided there.