# Sockets and connection states

**URL:** <https://www.ruby-forum.com/t/sockets-and-connection-states/161051>\
**Category:** Ruby\
**Created:** [February 22, 2009, 11:51pm UTC](https://www.ruby-forum.com/t/sockets-and-connection-states/161051 "2009-02-22T23:51:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbnnt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@bbnnt](https://www.ruby-forum.com/u/bbnnt)\
**Post date:** [February 22, 2009, 11:51pm UTC](https://www.ruby-forum.com/t/sockets-and-connection-states/161051/1 "2009-02-22T23:51:52Z")

</div>

I’m trying to wrap my head around socket programming and what the  
material I’ve been reading is telling me.

Say I have a firewall which allows traffic with connection state: NEW on  
a certain port for a short window of time(through port knocking or some  
other means). I have a second rule which allows all traffic with  
connection state: ESTABLISHED,RELATED that doesn’t decay.

My goal is to have server + client scripts that establish a new  
connection during that window and keep the connection open until the  
client script ends.

The questions:

Does it matter which type of socket I use? My n00b brain reads the  
descriptions and examples on UDP sockets as saying that it does matter,  
but at the same time I know I’ve run a few Doom servers with the same  
firewall scenario and I’m pretty sure it was UDP.

How does the firewall identify which data is “related or established”  
and how can I make sure that the scripts maintain that connection state?
