Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Socket Chat?! Pin
Heath Stewart29-Apr-04 8:36
protectorHeath Stewart29-Apr-04 8:36 
GeneralRe: Socket Chat?! Pin
Morten Kristensen30-Apr-04 4:08
Morten Kristensen30-Apr-04 4:08 
GeneralCreating an Access database at runtine Pin
bsargos29-Apr-04 7:11
bsargos29-Apr-04 7:11 
GeneralRe: Creating an Access database at runtine Pin
Heath Stewart29-Apr-04 8:33
protectorHeath Stewart29-Apr-04 8:33 
GeneralRe: Creating an Access database at runtine Pin
Dave Kreskowiak29-Apr-04 8:37
mveDave Kreskowiak29-Apr-04 8:37 
GeneralControl Box does not close form Pin
Darryl Borden29-Apr-04 6:52
Darryl Borden29-Apr-04 6:52 
GeneralRe: Control Box does not close form Pin
Heath Stewart29-Apr-04 8:31
protectorHeath Stewart29-Apr-04 8:31 
GeneralClient / Server Pin
Bonsai200429-Apr-04 6:20
Bonsai200429-Apr-04 6:20 
Hallo, my name is Axel. I´m in process of learning C#. and I want to realize the following problem:

- On a moblile computer runs a client, on my workstation a server application. I want to send simple commands from client to server. Depending on the received command the server application should do something (for example: open a picture, start internet explorer...)

- I want the server application to start once
so that the the client is (as often as necessary) able to connect/disconnect with the server to send data

- I've just tried a solution like the following, but it is not so good:

private void timer1_Tick(object sender, System.EventArgs e)
{
string[] Antwort = {"answer 1","answer 2","answer 3","answer 4"};
byte[] b = new byte[1];

Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);

Socket sa;

try
{
s.Bind(new IPEndPoint(IPAddress.Any,65000));
s.Listen(1);
sa = s.Accept();
do
{
sa.Receive(b);
if (b[0] > 0)
{
this.statusBarServer.Text = "Server open";
if(b[0] <6)
{
this.statusBarServer.Text = "send back: "+ answer[b[0]-1];
sa.Send(Encoding.ASCII.GetBytes(answer[b[0]-1]));
}
else
sa.Send(Encoding.ASCII.GetBytes("wrong question"));
}
else
{
sa.Send(Encoding.ASCII.GetBytes("CU"));
}
}

while (b[0] >0);
sa.Close();
s.Close();
this.statusBarServer.Text = "Server close";
}
catch(SocketException ex)
{
this.statusBarServer.Text = ex.Message;
}

}


I don't like using a timer for this particular problem. Can someone give me any help?

Thanks,
Axel
GeneralRe: Client / Server Pin
Heath Stewart29-Apr-04 6:46
protectorHeath Stewart29-Apr-04 6:46 
GeneralRe: Client / Server Pin
Andy Brummer29-Apr-04 6:46
sitebuilderAndy Brummer29-Apr-04 6:46 
GeneralRe: Client / Server Pin
Dave Kreskowiak29-Apr-04 8:45
mveDave Kreskowiak29-Apr-04 8:45 
GeneralRe: Multi-threading in a web service Pin
mjmcinto29-Apr-04 6:16
mjmcinto29-Apr-04 6:16 
GeneralRe: Multi-threading in a web service Pin
Andy Brummer29-Apr-04 6:39
sitebuilderAndy Brummer29-Apr-04 6:39 
GeneralRe: Multi-threading in a web service Pin
Heath Stewart29-Apr-04 6:49
protectorHeath Stewart29-Apr-04 6:49 
GeneralRe: Multi-threading in a web service Pin
mjmcinto29-Apr-04 12:44
mjmcinto29-Apr-04 12:44 
GeneralRe: Multi-threading in a web service Pin
Heath Stewart29-Apr-04 14:24
protectorHeath Stewart29-Apr-04 14:24 
GeneralRe: Multi-threading in a web service Pin
mjmcinto30-Apr-04 2:45
mjmcinto30-Apr-04 2:45 
GeneralRe: Multi-threading in a web service Pin
Heath Stewart30-Apr-04 3:14
protectorHeath Stewart30-Apr-04 3:14 
Generalprinting multiple pages Pin
nmah29-Apr-04 5:07
nmah29-Apr-04 5:07 
GeneralRe: printing multiple pages Pin
Heath Stewart29-Apr-04 5:37
protectorHeath Stewart29-Apr-04 5:37 
GeneralRe: printing multiple pages Pin
nmah29-Apr-04 7:26
nmah29-Apr-04 7:26 
GeneralRe: printing multiple pages Pin
Heath Stewart29-Apr-04 8:28
protectorHeath Stewart29-Apr-04 8:28 
GeneralRe: printing multiple pages Pin
nmah29-Apr-04 8:32
nmah29-Apr-04 8:32 
GeneralRe: printing multiple pages Pin
..Hubert..29-Apr-04 5:42
..Hubert..29-Apr-04 5:42 
GeneralScrewed up a service. Pin
Xian29-Apr-04 4:58
Xian29-Apr-04 4:58 

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.