473,657 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

issues on testing udp chat on same machine

2 New Member
hi, im creating a program that allows users to chat using udp sockets..

as a general description, what i did was fork a child process that sends a udp datagram via an ephemeral port while the parent listens on some specific port..

to test the program, i am using two different terminals on the same machine..

when i run the program on one terminal, i set the ip address to 127.0.0.2.. then, i run the same program in another terminal with ip address 127.0.0.1.. so when i send a message to 127.0.0.2 from 127.0.0.1, i indicate 127.0.0.2 as the destination.sin _addr (with the proper conversion of course)..

the problem is, when the program with ip 127.0.0.2 receives the datagram and i try to display the sender's ip (supposedly 127.0.0.1), it displays 127.0.0.2! the same goes when i send to 127.0.0.1 from 127.0.0.2 : the sender's ip displayed is 127.0.0.1 instead of 127.0.0.2!

1) is this an issue because i am only using loopback addresses? will this turn out all right when i am running the program on different computers and not using a loopback address?

2) and also, is there a way to specify on which port i would like to send a message to (and not on some ephemeral port)?

3) lastly, if i bind some program's, say program 1's, parent's socket (the listener) to an ephemeral port, and program 2's child (the talker) wants to send to program 1, what port will i indicate as the destination port? is there a way to know to what ephemeral port program 1's listener is bound to?

i dont have enough resources to setup a network so i am only limited to testing on the same machine :(

thanks a lot!
Mar 9 '08 #1
2 2229
sicarie
4,677 Recognized Expert Moderator Specialist
hi, im creating a program that allows users to chat using udp sockets..
Why use UDP? You're not streaming anything, so TCP would be a much more logical choice. Using UDP you have no receipt-verification process or re-sending of corrupt packets. This means entire chunks of the conversation could be lost without you knowing it.
as a general description, what i did was fork a child process that sends a udp datagram via an ephemeral port while the parent listens on some specific port..

to test the program, i am using two different terminals on the same machine..

when i run the program on one terminal, i set the ip address to 127.0.0.2.. then, i run the same program in another terminal with ip address 127.0.0.1.. so when i send a message to 127.0.0.2 from 127.0.0.1, i indicate 127.0.0.2 as the destination.sin _addr (with the proper conversion of course)..

the problem is, when the program with ip 127.0.0.2 receives the datagram and i try to display the sender's ip (supposedly 127.0.0.1), it displays 127.0.0.2! the same goes when i send to 127.0.0.1 from 127.0.0.2 : the sender's ip displayed is 127.0.0.1 instead of 127.0.0.2!

1) is this an issue because i am only using loopback addresses? will this turn out all right when i am running the program on different computers and not using a loopback address?
Hard to say without seeing your code.
2) and also, is there a way to specify on which port i would like to send a message to (and not on some ephemeral port)?
It is possible, but as I haven't done it recently, I'm going to recommend using Google.
3) lastly, if i bind some program's, say program 1's, parent's socket (the listener) to an ephemeral port, and program 2's child (the talker) wants to send to program 1, what port will i indicate as the destination port? is there a way to know to what ephemeral port program 1's listener is bound to?
Do you really need to know? Isn't all this stuff handled for you? You could always do a netstat on the machine you're unsure of, but there is also probably an easier way if you were to use the API of the OS this will be running on.
i dont have enough resources to setup a network so i am only limited to testing on the same machine :(

thanks a lot!
Mar 9 '08 #2
djsam931
2 New Member
thanks a lot for the reply.. i'll look into TCP..
Mar 9 '08 #3

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

Similar topics

0
3407
by: GrantS | last post by:
I need urgent help. Done OK for a newbie getting automation of Windows Messenger into a Winform C# app but have three problems that I urgently need pointers to. Point 1 and 2 are the same issue, I think. Point 3 might relate to a threading issue: 1. I have written a C# Winform application that uses Windows messenger automation. When I attempt to send a file through the window messenger object, there is some horrid screen flicking...
16
1770
by: clintonG | last post by:
I haven't installed VS2005 B2 yet. My main concern is installing VS2005 B2 on the XP Pro machine where VSN2003 already exists. Am I asking for trouble? Your comments... <%= Clinton Gallagher
2
1407
by: Tom Wells | last post by:
My server admin and I are trying to figure out how to get impersonation working to be able to upload a file from the client browser thru the web server to a network file server. My network ID for testing is twells. Our domain for testing is dev.com. If I don't have impersonation set in web.config the user ID shown by System.Security.Principal.WindowsIdentity.GetCurrent().Name is "twells/ASPNET" which does not exist on our network. If I...
3
5080
by: Michael Hoehne | last post by:
Hi, I'm currently facing a problem with a mixed environment using .NET 1.1 and ..NET 2.0 web services. We have a client application (the "client", system 1) running on .NET 2.0/WinXP, calling our web service (The "Web Service Server") running on a separate machine (also .NET 2.0, Win2003 Server, system 2). The web service server (system 2) itself makes calls to methods in the CRM
1
1906
by: Ted | last post by:
I managed to get it installed OK, along side MS Visual Studio 2005 (with which I received it). During the install, I made sure I installed everything. I have developed a number of applications using MySQL v 5 and PostgreSQL, but I have not worked with MS SQL. Playing with it after installing it, and running through several tutorials, I generally like what I see, but there are a few issues (so far - I am sure others will crop up as...
25
1616
by: Nathan Sokalski | last post by:
As we all know, IE7 is now available. However, it also cannot be installed side by side with IE6. This makes it very hard to test pages on both versions using the same machine. I am guessing that most businesses simply have multiple machines, some with IE6 and some with IE7. However, being a home developer who develops as both a personal hobby and potential career, I need a way to test both versions from home with the same machine. The only...
0
855
by: Gabriel Genellina | last post by:
En Mon, 09 Jun 2008 15:32:00 -0300, Marcelo de Moraes Serpa <celoserpa@gmail.comescribió: I don't think it's a problem with ElementTree. Perhaps you are writing the same (global) configuration file from several threads at the same time? You may need some locking mechanism in that case. -- Gabriel Genellina
3
2180
by: John Dalberg | last post by:
I am looking for an asp.net based chat software. I have looked at some (asp.net and php based) and they consist usually of a javascript piece where the web user (visitor) initiates a chat from a web page, an operator client which is usually a desktop app or browser based and the server part which serves as a controller between the operator and visitor, sending and receiving the chat text between them. What I have noticed is that the...
4
2222
by: =?Utf-8?B?dmlwZXJ4MTk2Nw==?= | last post by:
We are having an issue with an application we are developing. We have a Legacy COM DLL in C++ that we have converted to Visual Studio 2008. This COM DLL has methods that are calling Managed C# assemblies as pass thru to support legacy applications in an effort to move our code to the new Code base. Our COM Object can be instantiated on Windows XP in any COM supported environment using Visual C++, Visual Basic, ASP.NET or ASP and works...
0
8399
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
8312
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
8827
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
8732
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
8504
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
4159
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...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
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.