473,388 Members | 1,327 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,388 software developers and data experts.

Using Sockets in C#

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 one acts like
the 'server' and the other a 'client'. However, the 'server' is an
application that does some work, and one if its jobs is to launch the
other application and start communicating with it when a user clicks a
certain button. The other application will then open up and begin
passing data back and forth with the 'server'. The problem is, how do
I get the SERVER to INITIATE communication with a CLIENT instead of
waiting for a connection the way servers traditionally do?

Any ideas how I could approach this problem? Thanks!

~ M

Mar 16 '07 #1
3 1639
I just want to add that maybe the client/server architecture isn't
best for this scenario. I don't know if there's a way for me to have
the 'server' application spawn a new process that initiates
communication between the two apps? No idea how to get started!

~ M

On Mar 15, 8:04 pm, ahmed.mar...@gmail.com wrote:
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 one acts like
the 'server' and the other a 'client'. However, the 'server' is an
application that does some work, and one if its jobs is to launch the
other application and start communicating with it when a user clicks a
certain button. The other application will then open up and begin
passing data back and forth with the 'server'. The problem is, how do
I get the SERVER to INITIATE communication with a CLIENT instead of
waiting for a connection the way servers traditionally do?

Any ideas how I could approach this problem? Thanks!

~ M

Mar 16 '07 #2
Nevermind I figured out a solution to the problem. If anybody's
interested, the way I solved the problem was allowing my server to
call "sock.Listen", and then when the other application was launched,
I called "socket.Connect" in the client, passing it the IP address and
Port of the server. This way I can develop communication between two
C# applications where the server launches the client.

Thanks for reading!

~ Maryam
On Mar 15, 8:13 pm, ahmed.mar...@gmail.com wrote:
I just want to add that maybe the client/server architecture isn't
best for this scenario. I don't know if there's a way for me to have
the 'server' application spawn a new process that initiates
communication between the two apps? No idea how to get started!

~ M

On Mar 15, 8:04 pm, ahmed.mar...@gmail.com wrote:
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 one acts like
the 'server' and the other a 'client'. However, the 'server' is an
application that does some work, and one if its jobs is to launch the
other application and start communicating with it when a user clicks a
certain button. The other application will then open up and begin
passing data back and forth with the 'server'. The problem is, how do
I get the SERVER to INITIATE communication with a CLIENT instead of
waiting for a connection the way servers traditionally do?
Any ideas how I could approach this problem? Thanks!
~ M

Mar 16 '07 #3
You may encapsulate all the socket function into a dll-project. In this
project, you start tcp-listenning ,waitint for
client connetion. Then publishing a event when receive something form
client.

Your main project do not care any socket business,just refrence the
dll-project and subscribe the event.So the main
project can do what it want .

Surely, a lot of thread will be created in your project.
<ah**********@gmail.com>
??????:11**********************@n59g2000hsh.google groups.com...
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 one acts like
the 'server' and the other a 'client'. However, the 'server' is an
application that does some work, and one if its jobs is to launch the
other application and start communicating with it when a user clicks a
certain button. The other application will then open up and begin
passing data back and forth with the 'server'. The problem is, how do
I get the SERVER to INITIATE communication with a CLIENT instead of
waiting for a connection the way servers traditionally do?

Any ideas how I could approach this problem? Thanks!

~ M


Mar 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: feel52 | last post by:
Below you'll find the code i'm working on. It's in a button click routine and hangs after 3 or 4 sometimes 5 loops done, probably in sock.receive(....). Some code was found here( on google i mean)...
3
by: Raj | last post by:
I want to pass a C structure from a windows server to the C# client using the Sockets. Will there be requirements to cast the data types in the C# client?
3
by: Mr Mind - Lion | last post by:
Please send me some sample for using Raw sockets. And also clearly specify that how can I set the ip header of the protocol. Please help me. Thanx.
0
by: Jason L James | last post by:
Hi All, I am trying to send information from my vb.Net app to a piece of hardware with an embedded TCP/IP controller using sockets. I can send information so the sockets are working but the...
1
by: crashed | last post by:
Hi, I am using C# in .NET 2.0 and im trying to read a stream from a socket. The code works on the first attempt but fails on subsequent attempts. It is in a multithreaded application. It seems...
1
by: verge | last post by:
hello everyone! how's it going? like everyone in here im in need of some help and good friendship along the way...take a look at this: //MODIFIED SO IT DEALS WITH WINDOWS FTP USING ACTIVE...
2
by: Robbert van Geldrop | last post by:
Hello, I have a client that consumes a WebService using a WSE 2.0 sp3 interface. I use a WebProxy as generated by VS.Net, based on a webService URL. Occasionaly when debugging I get an...
3
by: jtagpgmr | last post by:
I need help coming up with a way to create a c# program to help me Telnet to a hostIP.. Any suggestions.. or a way to start..
4
by: billie | last post by:
Hi all. I'm (re)writing an FTP server application by using asyncore/asynchat modules. FTP tipically got two different channels: command and data. I'm succesfully managing command channel through...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.