nopasaran.tools.echo_socket_server.EchoSocketServer

class nopasaran.tools.echo_socket_server.EchoSocketServer

Bases: object

A simple echo server using sockets that echoes back any data it receives.

__init__()

Methods

__init__()

close()

start_and_wait_for_tcp_data(host, port, timeout)

Combine:

start_and_wait_for_udp_data(host, port, timeout)

UDP version:

start_and_wait_for_tcp_data(host, port, timeout)
Combine:
  • Creating a socket

  • Binding to (host, port)

  • Listening

  • Accepting exactly one client connection

  • Echoing data once

  • Returning the data and event

Returns:
(bytes or None, str):
  • The echoed data as bytes

  • The event name (REQUEST_RECEIVED or TIMEOUT)

start_and_wait_for_udp_data(host, port, timeout)
UDP version:
  • Create a socket (SOCK_DGRAM)

  • Bind

  • Wait for exactly one datagram

  • Echo that datagram to the sender

  • Return (data, event)