Re- imagining

Device Communication

attempt to improve expericence at localhost.

Edgar

Gulay

Software Engineer

@eddiegulay

Computer Networking

101

Important items

Focused in Local area networks*

1 - Addressing

IP Addresses

192.168.1.101

MAC Addresses

00:1A:2B:3C:4D:5E

2 - Data Transmission

Data Packets

Protocols

Role of Devices

*connected devices within a limited geographic area

Protocols

Transmission

Control Protocol

It is designed to send packets across the internet and ensure the successful delivery of data and messages over networks.

Black and White Houses

User

Datagram Protocol

It is specifically chosen for time-sensitive applications like gaming, playing videos, or Domain Name System (DNS) lookups.

💀

Getting Started


With Sockets in python

Following client server architecture to simulate communicationin LAN

Just Remember

Socket is:

software endpoint that establishes a communication channel between two devices over a network

Simply

Import the module

The module is built-in so there is no need for installation

Create connection Server

provides services or resources to other programs or devices

Create client instances

requests services or resources from a server in a networked environment

Creting Server

Create Socket Object and bing IP address and port

Accept incoming connections

socket.AF_INET

This specifies the address family (IPv4, represented by AF_INET)

socket.SOCK_STREAM

creating a TCP socket, and it implies that the communication will be connection-based and reliable

Creting Client

Connect to the Server

socket.connect((host, port))


connect to the server with the specified address and port.

Best Practices

When working with sockets ...

Threading and Concurrency

Consider using multi-threading or asynchronous programming to handle multiple connections concurrently.


This is especially important in scenarios with a high number of simultaneous connections.

Security Measures

Ensure that your application is protected against common security vulnerabilities, including injection attacks and unauthorized access.


Also make sure your data is properly encoded during transit

Best Practices

When working with sockets ...

Timeouts

Set timeouts on sockets to avoid blocking indefinitely.


This is crucial, especially in scenarios where you expect a response within a specific timeframe.

Address Reusability

This can be useful in scenarios where the socket is closed, and you want to reuse the same address quickly.


socket.setsockopt(

socket.SOL_SOCKET,

socket.SO_REUSEADDR,

1)


attempt

to make it

flexible and stable

echoSocket

this started as an experiment in search for realtime connection

between programs without the need for having REST APIs for communication.

?

What

is it trying to do

Stabilizing Connection

Sockets can be tricky when maintaing connection, one error - connection dies

Modular Task Execution

Making tasks executed in sockets portable

Attempting to create local-net playground for basic networking tasks

Pre

v

iew

v

tap image to open

Github Repository

EchoSocket

github.com/eddiegulay/EchoSocket.git