UDP server/client

I am using XE7.1 with the installed Indy.

I wrote an application that uses the client and server classes from indy 
for UDP to comunicate.

There are many servers on the same network, and potentially many clients.

THe client send a broadcast to the broadcast ip to get signal the servers, 
so they send back an ack that the client can discover the server ips.

All this works fine for me, however th way I implemented could be wrong.


My server is using the TidUDPServer only.

But my clients are using both, the TidUDPServer and TidUDPClient.

Since the UDPCLient is blocking when sending a message and it waits for 1 
message, and not many, I have added the UDPServer just to use the listening 
thread that it implements.

However this brings a problems, if I open more than client in the same computer 
it causes an error, probably because the PORT that I choose is in user already 
(idUDPServer is set to 44444)

So how to implement this?

How can I have a UDPClient with a listener thread?

or a UDPServer that shares the same port?

or my approach is all wrong, besides it works when only one client is running 
(that is 99,99% of the cases)

thanks....


Eduardo
0
Eduardo
7/14/2015 11:28:16 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

1 Replies
910 Views

Similar Articles

[PageSpeed] 17

Eduardo wrote:

> Since the UDPCLient is blocking when sending a message and it waits
> for 1 message, and not many, I have added the UDPServer just to use
> the listening thread that it implements.

Why not just have the UDPServer read everything?  You don't really need the 
UDPClient, you can send out data using TIdUDPServer as well, just send using 
the Binding that you want to receive a reply with.  In your OnUDPRead event, 
look at the packet data and act accordingly.

> However this brings a problems, if I open more than client in the same
> computer it causes an error, probably because the PORT that I choose
> is in user already (idUDPServer is set to 44444)

Correct.  You cannot have multiple servers on the same machine listening 
on the same port at the same time.

> How can I have a UDPClient with a listener thread?

Move the TIdUDPClient into its own thread, and let it block that thread on 
reading.  What is the problem?

> or a UDPServer that shares the same port?

You cannot.

> or my approach is all wrong, besides it works when only one client is
> running (that is 99,99% of the cases)

If you really need multiple clients on the same machine, you have to make 
them listen on different ports.  You could let the OS pick an available port 
for you (set the Binding.Port to 0), or you can make the clients communicate 
with each other to coordinate their port usage with each other.  Either way, 
you need separate ports, period.

-- 
Remy Lebeau (TeamB)
0
Remy
7/14/2015 11:52:56 PM
Reply:

Similar Artilces:

Indy 10
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_39eb5.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" The udp client component would be used in the datasnap server. The udp server component would be used in the datasnap client. --JivePart=_39eb5.zeB8CwDOH5aMJzMl Content-Type: application/x-zip-compressed; name="UDPDSClinetstub.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="UDPDSClinetstub.zip" UEs...

automation server to client and client to server
I have to applications that need to communicate with each other. Is it practical for both of them to be servers and clients to each other? One of the applications will work primarily as a server and will launch the other application. The newly launched application needs to be able to send occasional information to the server to update information in the application that launched it. Also, if the user attempts to close the launched application it needs to tell the launcher application to close the appl ication that it launched. Does this sound practical? This is kind of like launching wo...

Pass values from server to client and client to server?
Hi, i have a scenario, i want to  pass some values to an image and a label dynamically from database. i want to use an anchor(a href) tag and when the mouse goes over the anchor , an image url and label text must change with the values from database. Suppose that there are more than one anchor at the page.  One more thing, anchors must get the id values of the records from database at page_Load() and the queries use these these ids again to retreive imageurl and label text values from database when ...

Client & Server Side ( Server PostBacks Reset Client Data )
Hi, Slight Problem i have bumped into, maybe someone can help me... --TestSlider.aspx--------- <%@ Page Language="C#" %> <script runat="server"> void click(object sender, EventArgs e) { Label1.Text = Label1.Text; if(btnPress.Text=="Press") btnPress.Text = "PRESS"; else btnPress.Text = "Press"; } </script> <html> <head> <script language="JavaScript"> function newSlider(sId) { sCode = '<table border=...

c# server
I have serious problems with web-services. I implement this scenario: I developed a web-service in c# using VS2005. Here is my test method:   [WebMethod]  public string TwoStrings(string one, string two)  {   return one + two;  } When I use the web-service using a c# client it works. But when I use it with a delphi client, it returns always null. I used a SoapExtension to compare two requests. There are some differents: Request from C# (it works):------------------------------- <?xml version="1.0" encoding="utf-8"?> <s...

Start Client Timer from Server Event and start server Event from client event
All of you, I have a big challenge which i'm not able to resolve. I need some experts with samples on this. Situation for a webbased quiz system I have a data set with e.g. 5 questions. The process should be like 1. Load Question 1 from database, there is also a picture and a MP3 sound file 2. I connect the MP3 sound file to a webcontrol I've written to play Mp3 with a flashmovie. 3. Once this mp3 is played (the question is read for people with reading problems) an Event should be raised from the client to the server. 4. The event from 3 should start a Countdown timer (15 se...

Delphi 2009 Datasnap server and client
Hello, I am trying develop Datasnap server and client. I have a type TStringArray = array of string;. I used this type in one of server method. When I am trying to Generate Datasnap Client classes it says 'Remote error:Unknow data type: TStringArray'. How can I register this data type? -- Best Regards Md. Shariful Alam Khan Hello, Isn't there anyone to answer my question? Also I am getting same error if I use TStrings or TWideStringArray. Best Regards Md. Shariful Alam Khan "Md. Shariful Alam Khan" <murad_mouri@yahoo.com> wrote in messag...

Client-server to thin client
Hi all, we have a robust client-server application (PB 11.2, 70 pbls, 2000 objects) and a huge task to rebuild our application to be a thin client, where as a client side we are considering to use existing PB application GUI or Web Browser. We are about to make a big decision which way to go, so please recommend us what are the current possibilities now, in 2010, and what are the pros and cons. (Rewriting our application is not an option for us.) We are considering: - Appeon - Deploying PB nonvisuals to EAserver and use existing PB GUI as client - Migrating to .NET world with...

UDP client-server (Indy 9) [Edit]
Hi! I have a confusing problem using Indy 9 UDP client-server components (Turbo C++ 2006 Pro). I want to create a comunication where client sends a number to server and server returns to him the same number incremented by 1. void __fastcall TForm1::Button1Click(TObject *Sender) { int n = 5, m; // C1->Host = "127.0.0.1"; // C1->Port = 12000; C1->SendBuffer(&n, sizeof(n)); C1->ReceiveBuffer(&m, sizeof(m)); Application->MessageBoxA(IntToStr(m).c_str(), "Client got...", 0); } //---------------------------------------------------------...

How to receive UDP packets from a broadcast server/client?
Hello all, I do have a server/client app what is sending UDP packets on a specific port. I can receive those packets with a TIdUDPServer component, but the problem is I can only start 1 app on a PC and I need several more (different) apps on the same computer listening to the UDP broadcast. How can I resolve this? Thanks in advance for your answers. Regards, Henk. henk salomons <> wrote: >I can only start 1 app on a PC and I need several more (different) apps on the same computer listening to the UDP broadcast. >How can I resolve this? Don't know about Indy...

Server to Client server responses
Hello all, So now we have the client to server part down we need to decide the server to client. How will we notify the client for success/fail and we need to develop it in such a way that future "extensions" can add to it. For fail conditions we should send the standard 401 Unauthorized http response with the body being a message for the user using Content-Type: text/plain. For success conditions we send the standard 200 OK http response with the body being plain text content type like the error condition but encoded in such a way the client can parse it easi...

Reading a TDataset from a REST server in a Delphi Client
Hi, I wrote a REST Server in XE2 - that generally works fine - and I am able to use it from a Javascript client. We also wanted to use it in a Delphi client - and I have never written code with a Delphi client that accepts a dataset from a REST server. Basically, when I call my proxy (my Delphi code is in Delphi XE, where our client application is) - I get an error message, EDatabaseError 'Missing query, table name or procedure name' Any ideas what this is all about? I tried to replace the TDataset with a TClientDataset and the problem is the same. Any ideas where to con...

Blob Field through DataSnap Client/Server Delphi 2009
I can't pass Blob Field through DataSnap Client/Server Delphi 2009, when I try to Open the TSqlServerMethod this says Remote Error: unexpected metadata type, but, that only when the Table or Query have Blob fields. > {quote:title=ALEXANDER DAVID CRUZ MARQUEZ wrote:}{quote} > I can't pass Blob Field through DataSnap Client/Server Delphi 2009, when I try to Open the TSqlServerMethod this says Remote Error: unexpected metadata type, but, that only when the Table or Query have Blob fields. Hi. I have exactly the same problem. Seems it's not a just an error but it's a D...

Anyone using Delphi clients with Python socket servers?
Hi, Just wondering if anyone is using Delphi clients (indy or synapse) with Python based servers using threads or select from a single process. I have been playing around with Python as the server because its fairly similar to Delphi and runs on every OS. I have made a CRLF based server and a Synapse based client for sending and receiving popup notifications. So far the combo is great, but I am really wondering if anyone has done anything with sending streams(files or other binary data) from delphi to a Python server and how it was handled. -- Tony Caduto AM Software Design http:/...

Web resources about - UDP server/client - embarcadero.delphi.winsock

X.Org Server - Wikipedia, the free encyclopedia
X.Org Server refers to the X server release packages stewarded by the X.Org Foundation , which is hosted by freedesktop.org , and grants public ...

New GIGABYTE Server Motherboards Show Xeon D Round 2
... the most awesome product Intel has delivered in years, even if it is slightly hidden away from the mainstream’. There is interest both server ...

Linux bug imperils tens of millions of PCs, servers, and Android phones
(credit: amalthya ) For almost three years, millions of servers and smaller devices running Linux have been vulnerable to attacks that allow ...

Qualcomm will manufacture server chips in China
Qualcomm has entered an agreement with the Chinese province of Guizhou to enter into a joint venture to develop chips for server systems. This ...

I just got a look under the lid of all the servers you use when you check your Facebook news feed
... drone Aquila, given demos of Oculus and Samsung VR, and we also got up close and personal with the bits of Facebook you rarely see: Its servers. ...

Clinton's server had emails beyond top secret level
The Inspector General recently updated Congress on the contents of the former secretary of state's home server

Qualcomm sets up joint venture in China for server chips
Qualcomm is setting up a server chipset design and sales unit with a provincial government in China, a move that could help boost the company's ...

Report: Emails At The Highest Classification Levels Found On Hillary’s Private Server
Report: Emails At The Highest Classification Levels Found On Hillary’s Private Server

Netflix To Crack Down On Proxy Servers As Share Price Continues To Be Volatile
Netflix is cracking down on people using proxy servers to access the SVOD giant’s library. The use of VPNs (virtual private networks) was commonplace ...

Qualcomm teams up with Chinese province for server chips
... government's investment arm and 45% owned by a subsidiary of Qualcomm. The JV will focus on the design, development and sale of advanced server ...

Resources last updated: 1/20/2016 9:54:55 PM