Python server - sockets

For my multiplayer code, I am trying to make a python script that the server will run; and then blender clients connect to that server. But I guess I am still a little confused with socket programming. In each blender client I have a server socket to recieve commands and a client socket to send commands. In the server, I have one serversocket that is supposed to keep track of all the clients that are connected, and when it recieves a command, to send that command to the other clients.

Is this unnecesary? Can the client sockets in the blender clients both send and recieve messages? If this is true, how do I know if they are sending or recieving.

I am very confused :slight_smile:

Yes, I think you need two sockets then.

I work with blender and python sockets, and it works perfect for me, allthough I don’t use two -way communication. just be sure to set socket.set_blocking(0) or something like that. (I also use UDP sockets, not TCP)

check the documentation on python.org about socket module

The only problem is that you cannot load anything directly into blender, when you’re in runtime, (texture/model/action). If that could be made possible…

It would be so cool to have some virtual place to show of your latest models and actions :slight_smile:

It would be a very funny place indeed, maybe more like a 3d MUD, because everyone could add their own (interactive) environment.

Then you can walk from game to game …

it would be way better then activeworlds, and stuff like that.

Yeah, it’s a shame you can’t load external textures in realtime etc, but I think you can use the blender and the blender210 api’s to load/create models, textures etc, which will be updated when the scene is restarted. Not sure if it would work, I’ve never actually tried it.

So what are you working with sockets in blender for? A multiplayer game like me? If so, yours will probably be better :slight_smile:

It will be cool if I can implement the network code into level editor, but I’m not sure if that will work out.

Level editor is getting a bit too complex:)

i think, you are able to load and assign textures in the realtime engine :
you can load a image with the Image-module :

Image.Load(file)

with

imagelist = Image.Get()

you can achieve a imagelist of all images in the texturespace. Then you have to assign the new texture to the object (it should have already a texture). Get the faces of the object and assign the new texture with

face.image = imagelist [x]

Finally you have to update the object with

NMesh.PutRaw(object.data, object.name) 

WOW! Im lost, you guys amaze me, whats a socket? LOL…

NDNChief, so much to learn, so little time…

a little sock :stuck_out_tongue:

Martin

Such a cute little sock, oh come here socket, oh whos so cute?

You are:)

Sockets are a communication device, they talk to each other and are designed for network programming. Me, and aparently BlendedHKU as well, are working on multiplayer Blender games:)

I know this post was a long time ago. But I am confused. I do not see anywhere in the blender/python api documentation where sockets, or clients or servers are mentioned. Am I missing something?

Sockets aren’t in the blender api, but they do come with python. They allow networking to happen, and because blender has python support, you can use them in blender. Unfortunately, blender python does not come built in with sockets, so you have to have python installed for it to work.

I had a pretty good little demo working a while ago, but now it doesn’t.

I have another good long weekend up ahead of me, so maybe I’ll get it working by then?

I downloaded the full python package(?) from www.python.org and replaced the python.dll in the blender directory with the one I got from there so I suppose I do have the sockets module(?) Sorry I put the quetion marks in becasue I am not sure I am using the correct terminolgy. That is one thing that I think is lacking in the computer world, consistent terminology.

You aren’t suppose to touch the Python dll in the Blender distro, it’s there to stay there.

Martin

Then I am really confused. When I first tried running scripts, someone on this list said that the blender python.dll that you get with blender creator was and older version and that was why none of the scripts that I downloaded would run. So I download python 2.1 and put it in a seperate folder, becasuse I also want to learn the language outside of using it for blender. Then I reset the python path to include the new directory. Everything had been running MOSTLY fine since then.

You aren’t suppose to touch the Python dll in the Blender distro, it’s there to stay there.

Martin[/quote]

the Python dll in the Blender distro is not outdated. It contains the Python runtime library and all the modules needed by the Blender api. The modules that were not needed for the API are not included, that’s why you need to install the Python libs to run some of the scripts.

Martin