Jump to content
  • Advertisement
Sign in to follow this  
Floating

Anyone using SSL (Simple Sockets Library)?

This topic is 5391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am using SSL to communicate with another application through sockets. I have set up a server and a client. My client can send data, my server can send data and receive it (by polling with Stest). However my client can't do polling (it doesn't make an error, but everything becomes very very slow). Unless my server is always sending something and my client keeps reading with Sread, the application's screen gets refreshed every 2-3 seconds which is not normal. What can I have done wrong? Thanks for your help :)

Share this post


Link to post
Share on other sites
Advertisement
I didn't express myself very clearly, sorry...

What I mean is that my client application becomes very very slow if it doesn't read its socket on a regular basis (read with Sread). Meaning that my server needs to "feed" my client with trash data just to keep the client application fast. That is weird.
Also, when server and client are connected but no one is sending anything, I can hear some high frequency noise (very low volume) from my computer, like some data is being send..

Normally, shouldn't server and clients be able to just send and receive data when needed, the rest of the time doing some other job?

Please help I am desesperate :(

Share this post


Link to post
Share on other sites
Socket calls will block your application, meaning it just seems to stop. In reality, the read is waiting for data to arrive so it cn continue.

There are a couple of things you can do. In order of difficulty:
1. switch sockets to nonblocking mode. All calls return immediately, regardless of success or error.
2. use some sort of asychronous notification. This style of network I/O lets the network subsystem of your OS notify you when you are able to make a socket call without it blocking your application.
3. use a thread to make the calls. You then have to worry about marshaling data in and out of the thread, but the flow of execution is simple.

Share this post


Link to post
Share on other sites
Thank you antareus for your help.

I think I understand what you mean that calls will block my application. I expect a read to block my application, but what if I first test if something has arrived with test (Stest in the case of SSL) before reading it (with Sread)? That shouldn't block my application. Also if my client just connects and doesn't read/write anything my client application becomes very very slow. Is that normal?

Basically I want my client to ask my server for data. But I want my client not to wait for it (eg. with a read) but to continue with some other job. Then, from time to time I want my client to check if the data has arrived. But in my case the client just needs to connect to get damn slow.

Share this post


Link to post
Share on other sites
I'd caution against using something like Stest(). It is probably implemented in terms of doing a "peek" at the received data, which MS has an article on in their knowledge base. If you are trying to get something out the door then Stest() is probably fine, just don't rely on the buffer size that is returned.

As you're finding out, connections can be blocking as well. I'd recommend trying out some sort of notification mechanism, such as WSAAsyncSelect() if it is a Win32 GUI app. What is nice about WSAAsyncSelect() is that a window message is posted when socket events occur, such as a connection being finished, or data needs to be received. You just react to the events as they occur.

The choice of a network I/O model depends entirely on what sort of application you are programming.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!