|
Hello...
I have a server using TcpListener. Then I have also client using TcpClient.
The problem is : If I unplugged the network cable from server, then I try to send data from client to server, my TcpClient said "it is ok". But physically there is no connection between client and server.
My client said "it is NOT ok" only if I close all the connection in server (NetworkStream, TcpClient, and TcpListener). Otherwise is OK.
How can I solve the problem ?
Thanks...
|
|
|
|
|
There will always be buffering between client and server. TCP sends retries repeatedly until the Maximum Segment Lifetime (MSL, about two minutes typically) is exceeded or until the far end replies with an ACK (to accept the data) or a RST (reset) packet, indicating that the listening program isn't responding. If MSL is exceeded, or RST is sent, you'll get an error when you try to send data.
If you close the connection on the server side, the server's TCP stack will send a RST in response to unexpected data from the client because it no longer has a socket to deliver the data to.
You can't do anything about this - it's just how TCP works.
|
|
|
|
|
i have to use the same port for receiving and transmitting. i have two threads running. how do i control them meaning how is suspending thread of VC applied here in C#?
|
|
|
|
|
Thread.Sleep will suspend the current thread.
|
|
|
|
|
Hello,
i have started a c# project in Visual Studio 2003 on a PC running Win2000. Now i have moved the project to a Win XP machine and use Visual Studio 2005 to continue. The problem is although the designer shows all the controls placed on the form (buttons, numericUpDown and so on) in the new XP style, the runnig programm still uses the style of windows 2000. Is there anywhere a setting that makes my programm look like a normal XP Application.
|
|
|
|
|
Add a call to Application.EnableVisualStyles in your main method:
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I have a form that has several tab pages on a tabcontrol.
What I want to do is make sure that the user cannot tab/navigate to another tabpage whilst they are editing data on that tab page.
psuedo code:
EditButton_click event<br />
{<br />
this.tabpage1.locked = true;<br />
}<br />
<br />
SaveButton_click<br />
{<br />
this.tabpage1.locked = false;<br />
}
Any ideas.
TIA
Glen Harvy
|
|
|
|
|
Since Framework 2.0 the TabControl has a Selecting event that occurs before a tab page is selected and can be aborted. So you could set a boolean field inside the both click event handlers and inside selecting event handler abort the selection or not depending on the current value of the field.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks for pointing me in the right direction. I ended up with the following:
AddButton_click<br />
{<br />
this.tabControl1.Selecting += tabControl1_Selecting;<br />
}<br />
<br />
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)<br />
{<br />
MessageBox.Show("Please Cancel or Save your changes before going any further.", "Action required", MessageBoxButtons.OK, MessageBoxIcon.Question);<br />
this.tabControl1.Selecting -= tabControl1_Selecting;
tabControl1.SelectedIndex = 2; <-- I'll code this to refer to the appropriate calling tab page index.<br />
this.tabControl1.Selecting += tabControl1_Selecting; // in case the user didn't get the message the first time :)<br />
}
Thanks for being there - I don't know what I would do without this forum.
Regards,
Glen Harvy
|
|
|
|
|
The Selecting event lets you abort the selection of a tab page in a much nicer way:
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
{
MessageBox.Show("Please Cancel or Save your changes before going any further.", "Action required", MessageBoxButtons.OK, MessageBoxIcon.Question);
e.Cancel = true;
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Makes sense to me now thank you
Glen Harvy
|
|
|
|
|
Hello Friends,
I want the name of process and username under which it is running.
Like wise in taskmanager ImageName and UserName.
Thanks in advance.
Rahul Kulkarni.
|
|
|
|
|
Hello,
What do you have or what do you know about the process?
All the best,
Martin
-- modified at 5:29 Thursday 22nd February, 2007
System.Diagnostics.Process class has a lot of usefull methods!
|
|
|
|
|
I know all using for loop we can get all the processes
running in the task manager in the following manner.
foreach(Process prc in Process.GetProcesses())
{
////We can get all information like id of process etc.
}
But i want the "username" also under which the process is running.
how to get user name.
Rahul Kulkarni
|
|
|
|
|
I have no idea how you can do this.
Good luck
|
|
|
|
|
|
Thanks Alooot.
It's Really cool.
Rahul Kulkarni
|
|
|
|
|
hi
how can i make the new form appear in the center of the window?
i double click on the previous form opens this new one.
|
|
|
|
|
Hello,
Forms property "StartPosition" will help you.
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
All the best,
Martin
|
|
|
|
|
thank you so much.
one more thing.
on executing my application, when i try to resize the form, ie, by dragging or using the maximise button, it gets resized but the controls dont get done. they are at the same position as of the original form.
how do i resolve this?
|
|
|
|
|
Hello,
Use the Anchor or Dock property of the controls.
All the best,
Martin
|
|
|
|
|
thank you. i could do it by setting the Dock property.
|
|
|
|
|
You have to appropriately set the Anchor and/or Dock properties of the controls.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
thank you. i could do it by setting the Dock property.
|
|
|
|
|
I am new to Visual studio 2005.
In previous versions of Visual Studio, whenever you build a web application in debug mode, automatically a dll of the application used to get added in bi\debug folder.
Now in 2005 how do we create this dll?
please let me know ASAP.
Nana
|
|
|
|