I have a network with a InterBase database. On this database server I want a Delphi program what monitors the connections/data to and from the database.
So when a client connects to the InterBase server the Delphi program will catch the connection (port 3050) and passes it through to the InterBase (port 3050). So the program will have to listen to the same port as the InterBase?
The main purpose is to detect network problems like CLOSE_WAIT and other loss of connection to the database. I want to know when this happens. Also I want to cache the data, so when a connection problem occurs it can continue for some milliseconds. If connection is down for longer I want a signal to the clients, so they have to stop transmitting.
I am new to Delphi (and Indy). But I can’t find examples how to do this. All the search hits is how to make connections behind a proxy. But I have to make my own ‘proxy’.
I use Delphi XE2 – Indy 10.5.8.0
Related
I have a Datasnap application(Delphi 7) which uses TSocketConnectiom to connect to application server. If my application stays idle for a long time after opening a clientdataset, most of the times when i want to refresh the clientdataset the application freezes without raising any exceptions.It seems that the connection is dropped and the Socketconnection is not aware of that.I am experiencing this problem very often and I am not sure where can I find the solution. Could it be a bug in TSocketconnection?
Best Regards
Firewalls sometimes drop inactive TCP connections after some time to keep their cache usage low. In this case it helps to call some server method (maybe every five minutes).
If the "setup and teardown" code for the server side DataSnap session is not to resource-consuming, you can also disconnect and reconnect the DataSnap client between all actions. This will initiate a fresh TCP connection, execute, and close it.
I have a Delphi 6 application that exchanges audio data over a socket with an external hardware device. The hardware device has a problem internally where sometimes its internal buffer processing slows, especially during long periods of use, and nasty delays creep into the audio streams. This is a significant problem since the audio data frequently underlies a two way real time conversation between people. However, breaking the connection and re-establishing it fixes the problem.
I know how to close/disconnect a socket with Indy, that is quite easy. My concern is that some connection caching mechanism in Indy or the Windows socket layer itself may defeat my disconnect efforts if I try to re-connect too quickly. Is there a way to make sure that the socket connection with the external hardware device is truly broken? Better asked, is there a way to make sure that my re-connection attempt forces the creation of a fresh new socket (handle?) rather than re-using the old socket connection?
The external hardware device only "resets" if a brand new connection is created, probably because it flushes its internal queues and starts fresh (speculation on my part since I don't have the source code for the device).
Indy will not prevent you from re-connecting immediately. The only time Windows will do so is if you are assigning the same local port for the client to bind to each time. In that case, you have to wait for Windows to release that port for re-use. You can manually set the socket's linger option to disable Windows' delay and release immediately. Or don't assign a local port, and a random port will be used on each (re)connect.
I wrote a multi-tier application suite in Delphi XE, using DataSnap (VCL application).
This will be used internally, in my company, mostly to replace the outdated fax communication.
Everything works fine, but I came across an unpleasant situation: The server machine is behind a router, so it has an internal network IP. I forwarded (in the router) all incoming connections on port 211(DataSnap default) to the server's internal IP and about 8 times out of ten all the clients connect to the server without any problems.
The problem is that for the rest 2 times I get all sort of connection errors (mostly connection timed out). When it does this I have to close and reopen either the server application either (some of) the clients, and then it works.
Right now I'm still in the design phase, so it's only a bother, but when I do release it I don't want either to tell everyone NOT to EVER close the application (once it works, it works, no more problems), either close and reopen the applications each time there is a connection problem.
How can I eliminate this problem?
I had (only) a look at NetCat and SoCat, but (to me) it seems overkill for this situation. Is there another way to solve this?
The solution was switching off router's internal firewall.
I am a newbie in network related aspects. I have few basic questions related to tcp/ip protocol and network
If a network switch (in a LAN network) between two PC's running Client and server (that are communicating through async. sockets) is powered down. Can the client and server will be notified that the socket connection is no longer active. Client and server are running on Win XP OS and are coded using C#.
Does network topology play a role in case of half open connection between socket client and socket server. For e.g. Will a disconnect status of either one or both be notified to other end and does it depend on network topology.
Thanks in advance.
A network element such as a router/hub/switch does not activly cause anything anything to happen on the TCP layer if it goes down. The operating system might notice that the physical layer is down and error out all sockets bound on that network card if it's a network element directly connected to the PCs that breaks - this will vary among operating systems/network cards and other things. Other than that, in order to detect that the connection has been severed, you'll have to send something and rely on the TCP timeout mechanisms to error out. This can be done implicittly by enabling TCP Keepalives on the connection.
A disconnect on one side will only be noticed if those messages reach the other side, if the network topology changes or sometinhg breaks in the middle of the connection in such a way that messages no longer reach the other end, a disconnect won't be noticed. (NAT gateways are a big source of problems such as this, they might time out a TCP connection they're tracking and you'll never know the connection is no longer valid unless you try to write something (or enable TCP keepalives) to the connection). Note that most networking APIs require that you Read from the connection to discovver that a the other end has closed the connection - assuming those "close" messages actually reach your side.
I am connecting to a SQL Server Express 2005 on another PC on our company LAN.
On my PC (which has Windows7) the connection is immediate. On our tester PC (who has Windows XP), the connection takes about 5 to 6 seconds every time. This is the same network and the same server.
I am not talking about a connection through an application, but also through the control panel or anything else.
Any suggestion where this time difference may be coming from, what setup option might be involved or how we can speed up the connection on the XP PC?
Is the XP computer using an IPv4 address while you and the server are using IPv6? Could be an issue with the routers/switches along the way.