View Full Version : C++ SDL_net UDPPacket to Python Socket Server
06-05-2007, 02:40 PM
I'm trying to write a c++ client using SDL_net. It works, as I can see it sending data... nly problem is that it does not appear to send raw data in a simple function. It sends a UDPPacket which I'm trying to read at the other end with python. It must obviously be a unreadable for python, nevertheless it does recieve a packet... but I just cant 'print' it in a readable form.
Has anyone ever done this before? I know its a shot in the dark, but perhaps somebody has combined these two concepts before.
06-08-2007, 10:54 AM
I'm not very familiar with this combination (have done some socket programming in the past though, although I never bothered with anything else than TCP as a protocol), but could you try to make a small SDL_net app receiving your packets and see if anything gets mangled in between?
And in the section "totally ridiculous suggestions": Do you just send your data locally? (i.e. just on one machine, for testing purposes) or do you actually send to another machine. If so, could there be an endian issue between those two machines?
Don't know if any of these suggestions help you, but at least I tried. ;)
06-08-2007, 01:32 PM
hey, thx for the suggestions. They are indeed seperate machines, macbook pro and a p4. I'll have to create an SDL_net server I suppose to verify the data.
06-16-2007, 03:15 AM
In the end I discovered a really fantastic solution. Python has such simple networking itself that I really wanted to use it for both a client and a server. I couldn't link my C++ code with this so I looked at using SDL_net as the network client and a server in pure python. Then I discovered to my amazement that incorporating python and c / c++ is much easier than I had realised. I had looked into wrapper generators like SWIG but just discovered the brilliant ctypes module built into python 2.5! it allows loading of any type of shared dynamic library (DLL .so .dylib .framework) which means I can write the client part and program logic in python and the cpu hungry aspects in c++ and use native c libraries such as SDL and LibBASS. It is really simple to use a dynamic library in python I just had to share my experiences.
06-16-2007, 03:15 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.