[solved] Sockets: reuse receive() w/out creating socket new?

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years
Location: Stuttgart, Germany

[solved] Sockets: reuse receive() w/out creating socket new?

Post #1by Stuffer » 27.02.2009, 16:12

Hey,

I have a problem with using the socket library.
I managed to read from the socket via hook script.

Is there a possibility to reuse a created socket without reopening and reconnecting to the server socket?
What I want to achieve is setting up a socket only once and then connect to the server socket in the first tick by using a global counter.
Afterwards I only want to receive data from the socket for the rest of the time/ ticks.Long story short I want to keep a connection open and reuse it.

When I'm doing sth. like that until now my program is stuck when trying to receive data the second time and doesn't continue. When I set a timeout I get no data from receive() anymore but always a timeout error

So the only way to call receive() more often is to recreate my socket and reconnect to the same host and port again and again in every tick().

Why I'm trying to do this is because if reconnecting with every tick() Celestia seems to get data only about every second. And when I try to move the view (e.g. rotate the earth, ...) the movement is not very fluent.

Do you have experience with displaying not very well while reading data from a socket?

My server is from a simulator software and is able to write the data 25times a second if a client connect()s and receive()s
Last edited by Stuffer on 02.04.2009, 07:18, edited 1 time in total.
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years
Location: Stuttgart, Germany

Re: Sockets: reuse receive() without creating socket new?

Post #2by Stuffer » 19.03.2009, 13:02

I managed to reuse a socket by just creating a server and a connected client once and then receive on this client in an infinity loop.
That way I don't need to recreate the server and don't need to wait until it's unbind to bind on same port again.
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB


Return to “Development”