Click here to Skip to main content
15,893,594 members
Home / Discussions / C#
   

C#

 
AnswerRe: global debug variable? Pin
Jim Stewart24-Sep-03 5:34
Jim Stewart24-Sep-03 5:34 
AnswerRe: global debug variable? Pin
scadaguy24-Sep-03 8:42
scadaguy24-Sep-03 8:42 
AnswerRe: global debug variable? Pin
Alvaro Mendez24-Sep-03 8:52
Alvaro Mendez24-Sep-03 8:52 
GeneralRe: global debug variable? Pin
sharkfish24-Sep-03 9:11
sharkfish24-Sep-03 9:11 
QuestionHow to create TCP Listener windows service usingC# Pin
Baqer24-Sep-03 4:52
Baqer24-Sep-03 4:52 
AnswerRe: How to create TCP Listener windows service usingC# Pin
James Simpson25-Sep-03 2:19
James Simpson25-Sep-03 2:19 
GeneralRe: How to create TCP Listener windows service usingC# Pin
Baqer25-Sep-03 5:42
Baqer25-Sep-03 5:42 
GeneralRe: How to create TCP Listener windows service usingC# Pin
James Simpson25-Sep-03 22:36
James Simpson25-Sep-03 22:36 
Ok, my immediate advice would be to do the following:

1) Put the client connection into a new thread - for this you will need a new class with a member for the TcpClient object and a function for the thread. Reasonm being i think the Read function blocks the thread until it gets some data so your accept wont be getting called - unless the Accept also blocks, im not sure.

2) The ocrrect way to accept the connection you need to first see if a connection is pending, there is a Pending property/function on the listener, if this true then accept the connection, create a instance of the client thread class mentioned above - set a member variable of the class to the connection and start a new thread using the thread function you need to create in the new class. This leaves the server thread still available to accept more incoming connections. You need to keep track of the thread count and the _mbCloseThread information now, you could create a static instance of the data in another class and access it like that or pass in class with the thread counts and just make them public.

3) When receiving data from the client connection, you may want to read how much data is available and read the data accordingly, or you could use a BinaryFormatter and pass around an 'Envelope' (dont know if its the right terminiology but it fits!) object which is a wrapper class you create to store the data you want to send, eg:

Public Class MyEnvelope
{
string Data
}

Set the Data to what you want to send then use the BinarryFormatter to serialize it into the NetworkStream of the connection, and on the receive end, you can Deserialize from the stream.

Sorry if this doesnt make all much sense! I have just woken up!

Smile | :)

If you are still having trouble I will email you a simple client/server test service in C# I havent got one to hand at the moment, but I could put one together later.

Cheers, James


James Simpson
Web Developer
imebgo@hotmail.com
GeneralRe: How to create TCP Listener windows service usingC# Pin
Baqer27-Sep-03 0:50
Baqer27-Sep-03 0:50 
GeneralRe: How to create TCP Listener windows service usingC# Pin
Baqer28-Sep-03 22:36
Baqer28-Sep-03 22:36 
GeneralRe: How to create TCP Listener windows service usingC# Pin
James Simpson29-Sep-03 6:24
James Simpson29-Sep-03 6:24 
Generaldisable scrollbars of MDI Parent Form Pin
peenu24-Sep-03 1:29
peenu24-Sep-03 1:29 
GeneralRe: disable scrollbars of MDI Parent Form Pin
Gary Kirkham9-Oct-03 10:53
Gary Kirkham9-Oct-03 10:53 
QuestionHow to use AppDomain?!? Pin
ich_bins24-Sep-03 0:58
ich_bins24-Sep-03 0:58 
AnswerRe: How to use AppDomain?!? Pin
Nick Parker24-Sep-03 2:29
protectorNick Parker24-Sep-03 2:29 
GeneralRe: How to use AppDomain?!? Pin
ich_bins24-Sep-03 23:54
ich_bins24-Sep-03 23:54 
GeneralUML Designer with enteprise version of VS Pin
Andrew Torrance24-Sep-03 0:30
Andrew Torrance24-Sep-03 0:30 
GeneralVisual Studio Design time Pin
Velichko Sarev23-Sep-03 23:42
Velichko Sarev23-Sep-03 23:42 
GeneralA very odd problem Pin
morefalt23-Sep-03 23:18
morefalt23-Sep-03 23:18 
GeneralRe: A very odd problem Pin
scadaguy24-Sep-03 2:49
scadaguy24-Sep-03 2:49 
GeneralRe: A very odd problem Pin
morefalt24-Sep-03 5:16
morefalt24-Sep-03 5:16 
GeneralRe: A very odd problem Pin
scadaguy24-Sep-03 5:56
scadaguy24-Sep-03 5:56 
Generalinstaller conditions: ((CHECKBOXA1 And CHECKBOXA2) And Not (CHECKBOXA3)) is not working Pin
Chris Richner23-Sep-03 22:51
Chris Richner23-Sep-03 22:51 
GeneralRe: installer conditions: ((CHECKBOXA1 And CHECKBOXA2) And Not (CHECKBOXA3)) is not working Pin
ich_bins24-Sep-03 1:28
ich_bins24-Sep-03 1:28 
GeneralRe: installer conditions: ((CHECKBOXA1 And CHECKBOXA2) And Not (CHECKBOXA3)) is not working Pin
Chris Richner24-Sep-03 2:25
Chris Richner24-Sep-03 2:25 

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.