Click here to Skip to main content
15,902,883 members
Home / Discussions / C#
   

C#

 
GeneralException in web services Pin
Diego F.25-Aug-04 0:18
Diego F.25-Aug-04 0:18 
GeneralRe: Exception in web services Pin
Salil Khedkar25-Aug-04 2:54
Salil Khedkar25-Aug-04 2:54 
GeneralRe: Exception in web services Pin
Salil Khedkar25-Aug-04 2:59
Salil Khedkar25-Aug-04 2:59 
GeneralRe: Exception in web services Pin
Nick Parker25-Aug-04 5:37
protectorNick Parker25-Aug-04 5:37 
GeneralCheck if TCP/IP partner disconnected... Pin
Norman-Timo24-Aug-04 23:18
Norman-Timo24-Aug-04 23:18 
GeneralRe: Check if TCP/IP partner disconnected... Pin
leppie25-Aug-04 1:45
leppie25-Aug-04 1:45 
GeneralRe: Check if TCP/IP partner disconnected... Pin
Norman-Timo25-Aug-04 3:16
Norman-Timo25-Aug-04 3:16 
GeneralRe: Check if TCP/IP partner disconnected... Pin
Sebastian Schneider25-Aug-04 4:54
Sebastian Schneider25-Aug-04 4:54 
Hehe.

There IS a "Socket.Connected" property for Sockets.

I suspect that you are actually WAITING on that socket.

Do not do that. As far as I understand your problem, you have ONE Socket. That is, to say the least, not what anyone expects of a server.

Try understanding the concept of either synchronous sockets OR asynchronous sockets. If you choose the latter, you wont have to do any "manual multi-threading".

My last project at work was also a server waiting on TCP connections.

There is no "worst-case-handling" in there yet, but even if (due to network error or other problems) I lost a few clients, it would not block the whole thing down.

I am using asynchronous sockets, which means at runtime the necessary threads are auto-magically created in a threadpool.

The whole thing is based on the MSDN "non-blockingserverexample".

What you can do to check if your client still is connected: check socket.connection and socket == null (with proper capitalization, of course) or try sending something to your client. You will get an exception if your client is not connected.

I do have one advantage:
Once a client has connected, he will stream his requests one at a time (receive, process, answer - thats what I do) and each request has a length field in the leading five bytes.

So, if a Client has connected, I will immediately receive 13 byte from him, process his request, send my response, then receive the next 13.

I KNOW that a client who did not send me the proper shutdown package and has not responded for, lets say, thirty seconds, must be dead. So I can run over my (yet to be implemented) hashtable every thirty seconds and check for timeouts. That way, it will take less than sixty seconds for any dead sockets to be removed.
GeneralRe: Check if TCP/IP partner disconnected... Pin
Norman-Timo25-Aug-04 20:54
Norman-Timo25-Aug-04 20:54 
QuestionCan anybody explain me how does casting work *internally*? Pin
Salil Khedkar24-Aug-04 20:40
Salil Khedkar24-Aug-04 20:40 
AnswerRe: Can anybody explain me how does casting work *internally*? Pin
leppie24-Aug-04 21:06
leppie24-Aug-04 21:06 
AnswerRe: Can anybody explain me how does casting work *internally*? Pin
Sebastian Schneider25-Aug-04 5:12
Sebastian Schneider25-Aug-04 5:12 
GeneralRe: Can anybody explain me how does casting work *internally*? Pin
Salil Khedkar25-Aug-04 20:45
Salil Khedkar25-Aug-04 20:45 
QuestionAre there dynamic array librarys available in C#? Pin
gotton24-Aug-04 20:10
gotton24-Aug-04 20:10 
AnswerRe: Are there dynamic array librarys available in C#? Pin
leppie24-Aug-04 21:04
leppie24-Aug-04 21:04 
AnswerRe: Are there dynamic array librarys available in C#? Pin
Norman-Timo25-Aug-04 3:21
Norman-Timo25-Aug-04 3:21 
GeneralDrawing Pin
Member 1697724-Aug-04 18:29
Member 1697724-Aug-04 18:29 
GeneralRe: Drawing Pin
sreejith ss nair24-Aug-04 18:56
sreejith ss nair24-Aug-04 18:56 
QuestionFirst time using Windows Forms -- Components not appearing? Pin
Waverian24-Aug-04 17:23
Waverian24-Aug-04 17:23 
AnswerRe: First time using Windows Forms -- Components not appearing? Pin
sreejith ss nair24-Aug-04 18:53
sreejith ss nair24-Aug-04 18:53 
QuestionSingleton ? Pin
Christian Graus24-Aug-04 16:06
protectorChristian Graus24-Aug-04 16:06 
AnswerRe: Singleton ? Pin
Heath Stewart24-Aug-04 16:11
protectorHeath Stewart24-Aug-04 16:11 
QuestionHashtable error: "Object reference not set to an instance of ans object."! ??? Pin
gman4424-Aug-04 15:04
gman4424-Aug-04 15:04 
AnswerRe: Hashtable error: "Object reference not set to an instance of ans object."! ??? Pin
Charlie Williams24-Aug-04 15:33
Charlie Williams24-Aug-04 15:33 
GeneralRe: Hashtable error: "Object reference not set to an instance of ans object."! ??? Pin
Heath Stewart24-Aug-04 15:53
protectorHeath Stewart24-Aug-04 15:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.