473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sockets for communication!?

24
I have a Server side application and a Client side application, both written in C#

The 2 applications run on different machines, and I need bi directional communication. So i thought i would be using sockets. However, as i soon found out, it's not going to be simple!


assume that on the CLIENT, i have 2 methods:
- MethodA() //no parameters
- MethodB(String msg) //one parameter

Now, I want the SERVER to send a signal to the Client, so that the client will execute EITHER MethodA() OR MethodB(...).

Obviously, if the server wants MethodB(...) to be executed, then it needs to provide the value for the parameter!

Any ideas how to go about this!? Is it possible after all? If not, how would you tackle something similar?

Thanks
Mar 27 '07 #1
3 1300
RedSon
5,000 Expert 4TB
All you need to do is set up one connection to the server from the client. The server and client can talk bidirectionally if it is a TCP connection. You will want to look at the construction of the packet and how to get the information out of it. THat is going to be the key.
Mar 27 '07 #2
Guy007
24
All you need to do is set up one connection to the server from the client. The server and client can talk bidirectionally if it is a TCP connection. You will want to look at the construction of the packet and how to get the information out of it. THat is going to be the key.

Thanks for your reply RedSon!

When you say "construction of the packet" what do you mean exactly? I managed to send a string or a byte[] before using sockets.

Are you suggesting that I make a new class called "Packet", serialize it using a BinaryFormatter and stream, and send it over?

If I understood you well, the packet will hold a value indicating which method the client should run (eg an integer value, such as 0->Run MethodA(), 1->Run MethodB()). Is this the way to go about it, or is there something more 'elegant'...

Or have I completely misunderstood you!? :D

Thanks
Mar 27 '07 #3
RedSon
5,000 Expert 4TB
Thanks for your reply RedSon!

When you say "construction of the packet" what do you mean exactly? I managed to send a string or a byte[] before using sockets.

Are you suggesting that I make a new class called "Packet", serialize it using a BinaryFormatter and stream, and send it over?

If I understood you well, the packet will hold a value indicating which method the client should run (eg an integer value, such as 0->Run MethodA(), 1->Run MethodB()). Is this the way to go about it, or is there something more 'elegant'...

Or have I completely misunderstood you!? :D

Thanks
There is no need to construct a new class called Packet. The socket classes and the TCP classes should have a method for you to create payload for your packets. Have a look at this . These packets have a data area also called a payload. You will put your data in that payload, then on the other end you can take the packet's payload and deconstruct it.

So at one end you construct the packet, then fire it off into the ether through your socket. On the other end you wait for the packet to arrive, and when it does you take it from the ether and deconstruct it. The problem is what happens if the packet never arrives, or arrives late or a million other little things.
Mar 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dmitry Akselrod | last post by:
Hello everyone, I have a vb.net application that wraps the TCPListener object in a class. The server connects to the local interface and establishes itself on port 9900. It then polls for...
3
by: Tim Reynolds | last post by:
I support a .Net application running on a SERVER accessing MF Db2 data. Occasionally, we have some type of connection problem that we have been unable to debug up to this point. We typically...
15
by: kernel.lover | last post by:
Hello, i want to know to have multiple clients connects to same server program does following is correct code #include <sys/types.h> #include <sys/socket.h> #include <stdio.h> #include...
2
by: ZorpiedoMan | last post by:
I'm new to the world of sockets, and this question is not VB specific: If multiple clients access the same server on the same port, and the server is set up to do some async communication, does...
2
by: ZorpiedoMan | last post by:
I'm new to the world of sockets, and this question is not VB specific: If multiple clients access the same server on the same port, and the server is set up to do some async communication, does...
3
by: Michael Maercker | last post by:
hi! i'm really not into networking at all and have now been asigned the task of porting a vb6-code into vb.net (compact framework, in this case) and the code uses the winsock-control. i quickly...
10
by: altaf.sunesara | last post by:
Hello ! I have some devices which communicate trough LAN to the server the old form i was using was FTP as a communication between Server and Client i have decided to use personal TCP sockets...
2
by: a_agaga | last post by:
Do you know are there some reasons why many do not make processes to communicate through memory? Why network connections (sockets) are used so commonly in IPC (inter process communication)...
3
by: ahmed.maryam | last post by:
Hi all, I have a weird situation here in that I've designed two C# applications that need to communicate with each other using sockets. So I am trying to set the applications up in a way that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.