Python Sockets

Tags: , , , , , ,
Posted in dotnet, vb, vb.net | No Comments »

Hello there,

I’m currently working on a very simple script. It opens a socket and tries to read the incoming data. Currently I’m using the recv method which puts the entire incoming data in a single string variable. This is all fine but the package I’m receiving contains various data which I need to parse out.

The pattern in the package is rather straightforward, the first incoming integer tells me how long the incoming string is and after that a second integer telling me how long the second string is and so it goes. Here is my problem, how do I fetch the first integer from a string? Not thinking this was possible at all I started to look at buffers (from the Java ByteArrayBuffer) but I didn’t find what I was looking for. There was one method recv_into which takes a read-write buffer but I didn’t quite get that.

So, basically what I want to do is open a socket and read an integer or a string from that socket much similar to Java. Is this possible? I cannot be the first one trying out socket communication in Python! :)

Kind regards,
Niklas

Similar:

  1. Java and Binary data in the context of sockets Java newbie here. Are there any helper functions to serialize data in and out of byte arrays? I am writing a Java package that implements...
  2. Casting sockets to subtypes I’m trying to create my own subclass of socket.socket that will be able to handle custom messages. So far my code looks like this: self._sockets.append(s)...
  3. Problems writing a protocol on top of sockets in Java Hi, I’m writing a protocol on top of sockets, so I’ve decided to implement headers then send the information. So there is one thread per...
  4. Python TCP Server, writing to clients? Hi I have a tcp server which uses the select call to multiplex reading from clients. I have a client class (MClient) which manages the...
  5. java server not receiving object from client I have a client that sends a class object to the server. The server should invoke the methods of that class and return the result....

Tags: , , , , , ,

Leave a Reply