473,786 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1661
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...@gm ail.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.Liste n", 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...@gm ail.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...@gm ail.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**********@g mail.com>
??????:11****** *************** *@n59g2000hsh.g ooglegroups.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
5311
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) but the amazing( at least for me) is that if i run the program step by step or i cancel the loop and run it by pressing the button again and again it never hangs . I want to have an infinite loop so my socket keeps on listening until i...
3
4184
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
1911
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
323
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 data is garbage!!! It works if the ascii of the character I am sending
1
7402
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 the PlayerStream.Read() sets the PlayerSocket.Connected=false??? I am getting the following error: System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly
1
15637
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 CONNECTION //IMPORTANT: the logic is NOT complete, the program works only once and disconnects or freeze //One needs to modify or rewrite the program so it is fully functional for LIST and RETR
2
1817
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 unhandled expection in disassembly code: "Connection was forcidbly closed by remote host" stack trace:
3
6692
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
2168
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 asynchat framework, but I'm not sure about how to manage data channel without using a thread/subprocess. Is there an optimal to do that? Can anyone point me in the right direction?
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9496
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.