Click here to Skip to main content
16,005,038 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do i dock a window to the bottom of the screen? Pin
PhilDanger6-Jul-07 3:04
PhilDanger6-Jul-07 3:04 
GeneralRe: How do i dock a window to the bottom of the screen? Pin
jafingi6-Jul-07 3:05
jafingi6-Jul-07 3:05 
GeneralRe: How do i dock a window to the bottom of the screen? Pin
Martin#6-Jul-07 8:02
Martin#6-Jul-07 8:02 
GeneralRe: How do i dock a window to the bottom of the screen? Pin
ken.tachyon6-Jul-07 10:20
ken.tachyon6-Jul-07 10:20 
QuestionDatagrid in deviceApplication Pin
neer14-Jul-07 2:17
neer14-Jul-07 2:17 
AnswerRe: Datagrid in deviceApplication Pin
Diana Fernandez4-Jul-07 18:05
Diana Fernandez4-Jul-07 18:05 
GeneralRe: Datagrid in deviceApplication Pin
neer15-Jul-07 2:05
neer15-Jul-07 2:05 
QuestionTCP connection Pin
pmartike4-Jul-07 2:07
pmartike4-Jul-07 2:07 
Hi!

If i make a TCP server and i try to connect, the firs time it succeed but then i get an error message: "No connection could be made because the target machine actually refuse it". Frown | :(

<br />
private void AddLine(TextBox tb, string text)<br />
{<br />
if (tb.InvokeRequired)<br />
  {<br />
  AddLineDel d = new AddLineDel(AddLine);<br />
  this.Invoke(d, new object[] { tb, text });<br />
  }<br />
else<br />
  tb.Text += "\r\n" + text;<br />
}<br />
<br />
private void Listen_button_Click(object sender, EventArgs e)<br />
{<br />
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br />
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, port);<br />
<br />
sock.Bind(ipep);<br />
sock.Listen(2);<br />
sock.BeginAccept(new AsyncCallback(AcceptConn), sock);<br />
}<br />
<br />
private void AcceptConn(IAsyncResult iar)<br />
{<br />
Socket oldserver = (Socket)iar.AsyncState;<br />
client = oldserver.EndAccept(iar);<br />
AddLine(textBox1, "Connection from:" + client.RemoteEndPoint.ToString());<br />
Thread receiver = new Thread(new ThreadStart(ReceiveData));<br />
receiver.IsBackground = true;<br />
receiver.Start();<br />
}<br />
<br />
private void ReceiveData()<br />
{<br />
int recv;<br />
string datastr = "";<br />
while (true)<br />
  {<br />
  if (client.Connected)<br />
    {<br />
    cleardata();<br />
    recv = client.Receive(data);<br />
    datastr = Encoding.ASCII.GetString(data);<br />
    if (datastr == "exit")<br />
      break;<br />
    AddLine(textBox1, datastr);<br />
    }<br />
  }<br />
  client.Close();<br />
  AddLine(textBox1, "Connection closed");<br />
  return;<br />
  }<br />
}<br />


If anyone knows how to make a TCP connection where the same client can connect and disconnect multiple times.
Please help me! Thanks.

Regards,
Marta Paniti




--------------------------------
visit: http://pmartike.deviantart.com/

AnswerRe: TCP connection Pin
Sean Michael Murphy4-Jul-07 16:19
Sean Michael Murphy4-Jul-07 16:19 
GeneralRe: TCP connection Pin
pmartike4-Jul-07 19:34
pmartike4-Jul-07 19:34 
QuestionWidth of a document Pin
WhiteGirl234-Jul-07 1:37
WhiteGirl234-Jul-07 1:37 
AnswerRe: Width of a document Pin
Colin Angus Mackay4-Jul-07 1:43
Colin Angus Mackay4-Jul-07 1:43 
JokeOr... Pin
CPallini4-Jul-07 2:39
mveCPallini4-Jul-07 2:39 
AnswerRe: Width of a document Pin
Pete O'Hanlon4-Jul-07 1:46
mvePete O'Hanlon4-Jul-07 1:46 
GeneralRe: Width of a document Pin
WhiteGirl234-Jul-07 1:53
WhiteGirl234-Jul-07 1:53 
GeneralRe: Width of a document Pin
Pete O'Hanlon4-Jul-07 2:05
mvePete O'Hanlon4-Jul-07 2:05 
GeneralRe: Width of a document Pin
Christian Graus4-Jul-07 4:18
protectorChristian Graus4-Jul-07 4:18 
Questionhow to do validation of radiobuttons Pin
srinivassam4-Jul-07 0:55
srinivassam4-Jul-07 0:55 
AnswerRe: how to do validation of radiobuttons Pin
Tamimi - Code4-Jul-07 1:10
Tamimi - Code4-Jul-07 1:10 
AnswerRe: how to do validation of radiobuttons Pin
Muhammad Gouda4-Jul-07 1:44
Muhammad Gouda4-Jul-07 1:44 
GeneralRe: how to do validation of radiobuttons Pin
Ravindra Nidhonkar4-Jul-07 1:57
Ravindra Nidhonkar4-Jul-07 1:57 
GeneralRe: how to do validation of radiobuttons Pin
srinivassam4-Jul-07 2:27
srinivassam4-Jul-07 2:27 
QuestionReversing String-Recursive Pin
jalburzicon4-Jul-07 0:31
jalburzicon4-Jul-07 0:31 
AnswerRe: Reversing String-Recursive Pin
Pete O'Hanlon4-Jul-07 0:41
mvePete O'Hanlon4-Jul-07 0:41 
AnswerRe: Reversing String-Recursive Pin
CPallini4-Jul-07 2:36
mveCPallini4-Jul-07 2:36 

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.