473,761 Members | 5,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can we have same port for two UDP applications

2 New Member
Hi

I am writing a simple client server program in c# using sockets over UDP. Can I use same port for both the client and server to send and receive data (like in TCP) . I am trying to do the following but its not working.

sockListener = new Socket(AddressF amily.InterNetw ork, SocketType.Dgra m, ProtocolType.Ud p);

sockListener.Bi nd(ipEHost); // port 4050

when i do it on both server and client, an exception is thrown that only one app can open a port. but when i specify a different port on client or server (eg 4051) then it works fine.(client sends on 4051 and listens on 4050 and server does the otheway) What am i doing wrong to make both of them communicate over the same port.

Besides what calls do I need to make for sending and receiving Now I am using SendTo and Receive and it works fine when i specify different ports.

After initializing socket shall i use bind call for the server and the connect call for client? Whats the difference between connecting to local or remote endpoint with respect to UDP

Usman
Apr 12 '07 #1
0 1170

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

Similar topics

4
9704
by: Lizard King | last post by:
Hi. I have a computer running a third party software (POS). The thing is this application opens the printer port and I need to use another program while the first one is still running. Since the other app has the printer port windows shows an error (path/file access error). Is there a way that two applications can share the printer port?
1
2428
by: B or T | last post by:
How do you dynamically allocate a port number (assured that it is not already in use), and advertise it (by name or ID)? Every book I come across seems to hard code/configure a specific port number. This obviously won't work in general, if different applications try to grab the same ports, or if multiple instances of the application are running on the same machine (such as two instances of a client program requiring callback...
3
5040
by: Sagaert Johan | last post by:
Is there a c# solution for this ? It may work like the MSCOMM control. Applications that use the MSCOMM ocx should distribute this component too, so i want to avoid this. How can serial port access with overlapped io be done in c# ? Or should i fall back to the win32 api (createfile) with overlapped io ,and create a wrapper in managed code ? Any suggestions ?
3
7916
by: Ramakant Kasar | last post by:
Hi, If an application is reading data from a serial port, How can I open the same serial port with another application? Any idea? Please help. Thanks, Ramakant K.
3
1774
by: ZhangZQ | last post by:
I want to monitor the data send and receive in the comm port, is it possible to do this? Thank you very much!
1
2343
by: Stuart | last post by:
I am writing software to mimic the actions of a device connected to the serial port. I want my software to create a virtual COM port, so that other applications can talk to it. Is it possible to write a virtual device driver in c# for this? S.
2
11300
by: Alan P. Summerlin | last post by:
Hello All, I am about to start a new job and one of my first tasks will be to port an old VB (for DOS) application to VB.net. I have quite a bit of experience with VB 6.0 and no experience with VB.net (or VB for DOS). This application requires communications with external devices over the serial port (RS-232). I have written applications with VB 6.0 that perform serial communications over the serial port using the MSComm control, and I...
6
3277
by: Peter | last post by:
I'm interested to know what ideas are out there for reading a parallel port at a constant sample rate while still allowing the user to interact with the GUI. That is, reading it every 10ms for example without exception. Is this at all possible? Current tests done show that if the sample rate is 10ms then this is acheived in general, but when another program loads or terminates this 10ms jumps up to 100ms or more. In these tests the code is...
4
4816
by: max_mont | last post by:
Hi all, I'm a newbie in .NET technology. I've already developed Serial communication applications in C++ (WIN32). And I wanted to migrate to .NET technology. There is a serial component in framework to read and write on serial port. I would like to make asynchronous reception. I saw that we can pass a delegate to the serial class which is call when some data is readen on the port.
0
9377
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
10136
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9811
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...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
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
6640
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();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2788
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.