You don't need to worry about the details of the TCP connection (Threeway handshake, TCP flags, etc.) This is all taken care of by the OS. Don't think in terms of packets, but in terms of a connection. Don't worry about the transport layer, this is all handled automatically behind the surface.
You have only access to the packet payload, not the packet header.
Only once a TCP connection is established, data can flow, for example the telnet options negotiation. (Have a look at
this old thread). If you get the negotiation information, the TCP connection has been successfully established.