How to get the IP address of the firebird server I'm connected to? (with Delph7 + UIB) - firebird

I need to check, if the server I'm connecting to is local or an other PC on the LAN / VPN.
Using UIB API or SQL. (It's for data synchronization.)
Analyzing the connection string is impossible, since there are too many variation. (For example an alias, own pc name, IPv6, 127.0.0.3, ...)
select RDB$GET_Context('SYSTEM', 'CLIENT_ADDRESS'),
RDB$GET_Context('SYSTEM', 'DB_NAME') from RDB$DATABASE;
None of these gives back the Server IP, only the file location on the server.

Related

How does ping -a know the hostname of my Raspberry Pi 4?

My Raspberry Pi 4 B is connected (for the first time) to the WiFi of my PC (running Windows). Then the raspberry(ip) showed up in the list in Network Scanner of MobaXterm. What surprised me is that the list also shows the name of my Pi. And ping -a ip also shows the name.
How does this work?
When the Raspberry Pi connects to your WiFi it doesn't just get an IP address assigned. It also gets a host name assigned. It either sends its own host name to the DHCP server or the DHCP server assigns a host name.
Now, when you have an IP address, you can do a reverse search. Usually DNS works in the way that you give it a name and it returns the IP address. But there is also reverse search, give it an IP address and get a name back.
In your local network the DHCP server and your DNS resolver work together. Whenever a reverse search for a local IP address is made, the answer is fetched from the DHCP server. And the DHCP server answers with the host name from step one.
In most WiFi routers dnsmasq does this for you, on a Windows machine it is built into Windows.

How does a client socket application identify the server application on the same host computer

I have been trying to learn socket programming in C++ and got some progress for the basics. But I understood that basics are not fundamentals.
One of those fundamentals is about the question which is stated in the title. Lets say I have two separate applications running on the same computer. One of them has a server socket and the other one has a client.
When the server gets an IP address automatically, how can client find the server? Do I have to assign an IP address that is known by the client? In that case, maybe that IP address is not available on the network.
Or can client find and connect to the server by sone kind of name or id?
Have the server bind to all interfaces and have the client lookup 'localhost' by name; it's resolved locally, (ie. no external DNS service required), to an IP address stored in a 'hosts' file, and is set by default to 127.0.0.1
Google 'hosts file'
The IP address of any server in the same host is 127.0.0.1 unless the server has bound to a specific, different IP address. As #MartinJames points out, you can use 'localhost' as the hostname for that, except on certain broken Linux distributions.

Hosting Perforce server on internet?

I am configuring my system (OSX) as a perforce server for sharing my project work with my coding partner. I want to host my server on the internet so that he will able to connect to my system. I am able to configure through this guide.Working like charm on my local host.
Maybe i am not getting something.
Please guide me to find an address or what procedure I have to do extra for making my system available to my partner .
I am very bad in UNIX terminal command
i tried these links but no answer worked for me .
Perforce with dynamic ip
Online Perforce Repositories
Some questions
Is there any need for static IP .
How i make my system available to partner over internet?
This is my p4 info.
User name: aadi
Client name: aadi-MacBook-Air
Client host: aadi-MacBook-Air.local
Client unknown.
Current directory: /Users/aadi
Client address: 127.0.0.1:50596
Server address: localhost:1666
Server root: .
Server date: 2014/11/18 01:58:14 +0530 IST
Server uptime: 00:00:10
Server version: P4D/DARWIN90U/2011.1/747877 (2013/11/21)
Server license: none
Case Handling: insensitive
I don't believe you need a static IP, so long as your partner can connect to you using your dynamic IP.
Your server has to listen on an IP address which is accessible by your partner, so "localhost:1666" will not work, because 'localhost' means to only accept connections from your own machine.
If your machine, was, say 192.168.1.101, then you'd like to see something like:
Server address: 192.168.1.101:1666
Which you should be able to accomplish by starting your server as 'p4d -p 192.168.1.101:1666'.
You can also try starting your server at 'p4d -p 1666' and see if it will listen on an address that is accessible by your partner's machine. It should, but occasionally there are problems if the IP address is not explicitly specified. If you explicitly specify your machine's IP address, and it is a dynamic IP, then you will have to stop and restart your server on the correct IP address each time your machine's IP address changes, which is rather an annoyance (and is avoided if you can in fact deploy a static IP).
All this business about static vs dynamic IP addresses should go away if your dynamic IP assignment mechanism is well-integrated with your organization's DNS infrastructure, so that your partner can use the hostname of your computer rather than the IP address.
Lastly, don't forget to check your OS X firewall: http://support.apple.com/en-us/HT201642

Database Mirroring - App Can't Connect to Mirror - Named Pipes Provider: Could not open a connection to SQL Server [53]

I have an application that can connect to the Principal, but can't connect to the Mirror during a failover.
(Note to moderator: please let me know if this question is more appropriate for serverfault. I posted it here because I found more questions similar to this issue than on serverfault.)
This is the error I receive when my application attempts to connect to the Mirror after a failover:
Named Pipes Provider: Could not open a connection to SQL Server [53].
Cannot open database "MY_DB_NAME" requested by the login. The login failed.
I am familiar with the fact that when initially connected to the Principal, the name of the Mirror server is cached to be used during the failover and that the failover partner I specify in my connection string is only used if the initial connection to the Principal fails.
This clearly describes the problem I'm having:
http://blogs.msdn.com/b/spike/archive/2010/12/15/running-a-database-mirror-setup-with-the-sqlbrowser-service-off-may-produce-unexpected-results.aspx
...but the SQL Browser Service is running and I can't figure out why the name won't resolve when connecting to the mirror.
I'm assuming there is a service that must be running to enable NetBIOS name resolution that is not running, because this is what I see in WireShark consistently without a response from the Mirror:
Source Destination Protocol Length Info
10.200.3.111 10.200.5.255 NBNS 92 Name query NB SQL-02-SVR-<00>
Question 1: What could be causing the problem? ;-)
Question 2: I really don't want to enable NetBIOS (for security reasons) and I'm using IP addresses (no FQDNs) in the mirror configuration and in the connection string. Given the caching behavior of the mirror partner when connecting to the Principal, is there a way to force TCP/IP to be used so the value that is cached is the IP address and not the name? Do I need to run the SQL Server Browser/Computer Browser services?
The configuration:
App Is Delphi XE2 using SDAC 6.5.9 (I don't think this is relevant to the component I'm using because it works in other installations with mirroring and has no issues)
SQL Server 2012 Enterprise installed as a default instance on Principal, Mirror and Witness in a non-domain configuration using certificate authentication.
Windows Server 2008 R2 SP1 64-bit on all machines
Firewalls disabled on Principal, Mirror and Client (where app is running)
TCP/IP and Named Pipes enabled on Principal and Mirror
SQL Server Browser service running on Mirror
Computer Browser service running on Mirror
Mirroring is configured for automatic failover with a witness and works properly (I can fail back and forth between mirror and principal without issue)
SQL Native Client 2012 installed on Client machine
Same app login (with same SID and user rights) exists on both Principal and Mirror
Correct server, failover partner, database name, user name and password verified in my app log
In connection string, principal server is 'tcp:10.200.3.15,1433' and failover partner is 'tcp:10.200.3.16,1433' using the SQL Native client
I can ping both servers from the Client machine
NetBIOS over TCP/IP has been enabled in the adapter under the WINS tab (on the Mirror and Client machines)
I've been able to get the application working with mirroring on several other installations, but this one is baffling me.
I found the problem, which was that the customer had the Principal and Mirror in one VLAN and the Client(s) in another. Although the IP addressing scheme was the same, the policy for communication between the VLANs prevented broadcast messages, which is why the NetBIOS query was failing on the client. A WINS or DNS server will be implemented to resolve this issue.
However, I am still interested in an answer to my Question #2, above.

Connect Local Host from Web Service

I have a Laptop, with msSql sever 2005, and it is connected to my Wifi router which gets the internet. So My laptop get connected to internet. But I need to access my msSql Sever from internet to connect my webpage which I made using ASP.Net.
Please Help me... And please give a solution for this...
You'll need your IP adress to connect, then open the SQL-Port in your router. (default is 3306)
When you connect to the server just use your current ip adress.
Maybe you want a static ip or something like http://dyndns.org
you want to write web service and host that service in sql machine
First setup a static IP address on your laptop and after that you need to set up port forwarding in your router. This process differs slightly depending on your routers manufacturer and model.
After this is set up properly make sure that SQL Servers port is open on your laptops firewall.
By using Dynamic DNS you can point to your possibly changing IP address with static name so you don't have to change this constantly in your connection string.