Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone
I want to write a simple server-client application , the main pursue is for it is to run a script of some type via GUI after connection established , so basically
I want to make connection conformation

what I have now is

internal bool connect(remoteIP)
{
 if ( network.startping(RemoteIP))
 {
  peer1.write("Hello!") ---> waits for "connected" until time out 
  if (Isconnected) return true
 }
 else 
  {
   try again after few sec with finite number of repeats
  }
 return false
}

1) what can I do to wait I saw a way with
C#
Task wait = new task.factory(()=> doDwaiting())
with I think can work , but I I'm missing some logic here 2) how can I make the return i think I can Do it with int Counter and goto but it doesn't look like the "good" way to go

what can I do ?
Posted
Updated 11-May-14 1:22am
v2
Comments
Emre Ataseven 11-May-14 5:21am    
You may call connect(remoteIP) with an iterator in else block
Matan Fihman 12-May-14 2:58am    
please expand on your idea if you can :)

1 solution

Socket.ReciveTimeout[^] could help you achieve this objective.
 
Share this answer
 
v2
Comments
Matan Fihman 11-May-14 7:00am    
I'm a bit new in programming , can you please a small example(pseudo-code would be fine ) so I can learn of a proper way to accomplish this type of tasks ?
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900