Click here to Skip to main content
15,889,116 members
Home / Discussions / C#
   

C#

 
GeneralRe: Centering a window at runtime? Pin
Zinj21-Sep-02 15:43
sussZinj21-Sep-02 15:43 
GeneralRe: Centering a window at runtime? Pin
James T. Johnson21-Sep-02 15:50
James T. Johnson21-Sep-02 15:50 
GeneralRe: Centering a window at runtime? Pin
Zinj22-Sep-02 4:51
sussZinj22-Sep-02 4:51 
GeneralRGB and HSV Pin
Tomas Petricek21-Sep-02 4:43
Tomas Petricek21-Sep-02 4:43 
GeneralRe: RGB and HSV Pin
leppie21-Sep-02 5:34
leppie21-Sep-02 5:34 
GeneralRe: RGB and HSV Pin
Stephane Rodriguez.21-Sep-02 5:42
Stephane Rodriguez.21-Sep-02 5:42 
GeneralRe: RGB and HSV Pin
leppie21-Sep-02 5:55
leppie21-Sep-02 5:55 
GeneralRe: RGB and HSV Pin
Tomas Petricek21-Sep-02 6:19
Tomas Petricek21-Sep-02 6:19 
GeneralScrolling Metrics Pin
leppie21-Sep-02 3:53
leppie21-Sep-02 3:53 
GeneralMulticolored Text Pin
Stickman21-Sep-02 1:38
Stickman21-Sep-02 1:38 
GeneralRe: Multicolored Text Pin
leppie21-Sep-02 1:51
leppie21-Sep-02 1:51 
GeneralRe: Multicolored Text Pin
Philip Fitzsimons23-Sep-02 7:14
Philip Fitzsimons23-Sep-02 7:14 
Questionhelp ( form message releted )? Pin
imran_rafique20-Sep-02 15:59
imran_rafique20-Sep-02 15:59 
AnswerRe: help ( form message releted )? Pin
James T. Johnson20-Sep-02 16:37
James T. Johnson20-Sep-02 16:37 
Questioncan any body help (releated to hook )? Pin
imran_rafique20-Sep-02 15:03
imran_rafique20-Sep-02 15:03 
Generalsocket timeout Pin
Rüpel20-Sep-02 3:27
Rüpel20-Sep-02 3:27 
GeneralRe: socket timeout Pin
Luis Alonso Ramos20-Sep-02 4:37
Luis Alonso Ramos20-Sep-02 4:37 
GeneralRe: socket timeout Pin
Rüpel22-Sep-02 22:23
Rüpel22-Sep-02 22:23 
Generalthis is not solved yet Pin
Rüpel23-Sep-02 4:00
Rüpel23-Sep-02 4:00 
GeneralRe: socket timeout Pin
Daniel Turini23-Sep-02 9:16
Daniel Turini23-Sep-02 9:16 
GeneralRe: socket timeout Pin
Rüpel23-Sep-02 10:09
Rüpel23-Sep-02 10:09 
Generalstill doesn't work Pin
Rüpel23-Sep-02 20:52
Rüpel23-Sep-02 20:52 
Generalfinally Pin
Rüpel23-Sep-02 21:53
Rüpel23-Sep-02 21:53 
now i did a 'hack' that works for me. Smile | :)

public class TimedUdpClient : UdpClient
{
	private int timeout = 1000; // 1 sec default
	private Thread timeoutWatchdog;

	/// <summary>
	/// Get/Set the receiving timeout in milliseconds (1000 = 1sec)
	/// </summary>
	public int Timeout
	{
		get { return timeout; }
		set { timeout = value; }
	}

	public new byte[] Receive(ref IPEndPoint remote)
	{
		timeoutWatchdog = new Thread(new ThreadStart(StartWatchdog));
		timeoutWatchdog.Start();
		try
		{
			byte[] ret = base.Receive(ref remote);
			return ret;
		}
		catch (SocketException)
		{
			return null;
		}
	}

	private void StartWatchdog()
	{
		Thread.Sleep(timeout);
		this.Send(new byte[] {0x00},1,"",8000);
	}
}


my little test-program from two or three postings above didn't receive the packets since they have to be sent on the same socket (at least i believe that). when this byte from my watchdog is sent, there's an exception ("connection closed by remote" or something like that) raised somewhere inside UdpClient.Receive(). it would be nicer, if it would just receive the byte and one could distinguish by the sender, if that packet was sent by the watchdog (thus, on the same socket) or comes from outside. UDP is a connectionless protocol, so i'm not sure, how such a connection-closed-excpetion may occur, but actually it does WTF | :WTF:

anyways. all i wanted, was stop Receive() from blocking and this way it works. Smile | :)

thx to everyone that helped. (also the ones that read, thought and had no idea)

:wq
GeneralEiffel .NET for Visual Studio .NET Plug-in Pin
Kevin McFarlane20-Sep-02 1:50
Kevin McFarlane20-Sep-02 1:50 
GeneralBackground and foreground color for disabled state Pin
valos20-Sep-02 1:18
valos20-Sep-02 1:18 

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.