Click here to Skip to main content
15,913,934 members
Home / Discussions / C#
   

C#

 
GeneralRe: Question about Marshal Pin
momer6-Nov-04 23:47
momer6-Nov-04 23:47 
GeneralRe: Question about Marshal Pin
Uwe Keim7-Nov-04 20:26
sitebuilderUwe Keim7-Nov-04 20:26 
GeneralRe: Question about Marshal Pin
momer7-Nov-04 22:58
momer7-Nov-04 22:58 
GeneralRe: Question about Marshal Pin
yoaz6-Nov-04 22:22
yoaz6-Nov-04 22:22 
GeneralRe: Question about Marshal Pin
momer6-Nov-04 23:41
momer6-Nov-04 23:41 
GeneralRe: Question about Marshal Pin
yoaz7-Nov-04 0:52
yoaz7-Nov-04 0:52 
GeneralRe: Question about Marshal Pin
momer7-Nov-04 2:28
momer7-Nov-04 2:28 
GeneralHandle Threads and blocking UDP Connection Pin
Snowjim6-Nov-04 13:57
Snowjim6-Nov-04 13:57 
Hey!

I have a Server/Client program.

The client is sending 4 packages to the Server and the server echo this pacakges back to the client that calculate the time and loose of packages.

I use UDP blocking Connection and threds, like this

				byte[] data = new byte[64*1024];<br />
				IPAddress addr = Dns.GetHostByName(this.GUI.txtIPAdr.Text).AddressList[0];<br />
				dest = new IPEndPoint(addr,int.Parse(this.GUI.txtPort.Text));<br />
				iend = dest;<br />
<br />
				for(int i = 0; i<4;i++)<br />
				{<br />
<br />
					this.GUI.lblStatus.Text = "Sending";<br />
<br />
					Thread Reciving = new Thread(new ThreadStart(ReciveMessage));<br />
<br />
					data = Encoding.Unicode.GetBytes(this.GUI.txtMessage.Text + " " + i.ToString() + " to " + dest.ToString());<br />
					<br />
					interval = DateTime.Now;<br />
					client.SendTo(data,(EndPoint)dest);<br />
					Reciving.Start();<br />
<br />
					Thread.Sleep(2000);<br />
<br />
					if(Reciving.IsAlive)<br />
					{<br />
						Reciving.Abort();<br />
					}<br />
<br />
				}<br />
				this.GUI.lblStatus.Text = "Stopt";<br />
				client.Close();<br />
				this.GUI.button1.Enabled = true;


in the ReciveMessage i use

client.ReceiveFrom(data,ref end);

The problem it, if the second packages is lost, then the rest will also be lost, i think that the thread that is running the Recive function the second turn(when there is no answare from the server) is looking then blockt client.ReceiveFrom and there by the other threads cant use this function to get teh pending echo from Server.

Shold i remake to nonBlocking mode? or is there a way to use the Threads better?
The best is if i could close a Thread when the time is finish(thread.sleep(2000)) but Reciving.abort() is not always removed instantly by the garbage collector.

I need the Thread to releas the resurces it got so other threads can use it.

//Jimmy
GeneralRe: Handle Threads and blocking UDP Connection Pin
Sebastian Schneider7-Nov-04 19:57
Sebastian Schneider7-Nov-04 19:57 
GeneralI just don't get ann's Pin
tom_dx6-Nov-04 13:22
tom_dx6-Nov-04 13:22 
GeneralRe: I just don't get ann's Pin
yoaz6-Nov-04 22:09
yoaz6-Nov-04 22:09 
GeneralCircular Reference Hell! Pin
RFickling6-Nov-04 12:55
RFickling6-Nov-04 12:55 
GeneralRe: Circular Reference Hell! Pin
Colin Angus Mackay6-Nov-04 13:16
Colin Angus Mackay6-Nov-04 13:16 
GeneralRe: Circular Reference Hell! Pin
RFickling6-Nov-04 13:30
RFickling6-Nov-04 13:30 
QuestionI need a simulator for ..........? Pin
Sakkijha6-Nov-04 11:38
Sakkijha6-Nov-04 11:38 
AnswerRe: I need a simulator for ..........? Pin
tom_dx6-Nov-04 11:51
tom_dx6-Nov-04 11:51 
GeneralRe: I need a simulator for ..........? Pin
Sakkijha6-Nov-04 12:03
Sakkijha6-Nov-04 12:03 
GeneralRe: I need a simulator for ..........? Pin
tom_dx6-Nov-04 13:12
tom_dx6-Nov-04 13:12 
AnswerRe: I need a simulator for ..........? Pin
Christian Graus7-Nov-04 15:31
protectorChristian Graus7-Nov-04 15:31 
Questioncan't get two EXEs to share the same DLL? Pin
vista276-Nov-04 11:16
vista276-Nov-04 11:16 
AnswerRe: can't get two EXEs to share the same DLL? Pin
Colin Angus Mackay6-Nov-04 12:59
Colin Angus Mackay6-Nov-04 12:59 
AnswerRe: can't get two EXEs to share the same DLL? Pin
Dave Kreskowiak6-Nov-04 17:14
mveDave Kreskowiak6-Nov-04 17:14 
AnswerRe: can't get two EXEs to share the same DLL? Pin
Peff6-Nov-04 17:25
Peff6-Nov-04 17:25 
QuestionDetect Server Software (i.e. Apache)? Pin
Justin Garrick6-Nov-04 8:47
Justin Garrick6-Nov-04 8:47 
QuestionIdentify this form? Pin
Justin Garrick6-Nov-04 8:03
Justin Garrick6-Nov-04 8:03 

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.