Open Socket fails if executable is on a network share - windows-7

We have the problem that we are not able to open a socket, if the executable is on a network share:
errortext we get:
0.0.0.0:2220: In TcpipSocket::TcpipSocket: Invalid argument.
Some invalid argument was supplied (for example, specifying an invalid level
to the setsockopt function). In some instances, it also refers to the current
state of the socket-for instance, calling accept on a socket that is not
listening.
The real adress should be 127.0.0.1.
the program works fine if the exe lies on my local HDD
I'm suspecting "security" related reason, Like MS doesn't allow opening sockets from network shares
or something similar.
Somebody has some clue?
The program is written in C++ using Win32api

I found the solution in the MSDN Forum
If you are interested, details can be found here
social.msdn.microsoft.com

Related

How do I close a socket (ipv4 and ipv6) connection on Windows from any process?

How do I close tcp v4 and tcp v6 connections on Windows? I don't want to kill the entire process that has the open connection as this obviously will kick everyone else off that process. I need to do this from a separate process, and so will not have access to socket handles, etc. I am using Windows API to get tcp table, etc. so I know which connections are active.
One way might be to enumerate all open handles on the system, or at least the open handles of a given target process, until you find the SOCKET handle you are interested in (see HOWTO: Enumerate handles, Socket Handles, and C++ Get Handle of Open Sockets of a Program - though I'm not sure how you would be able to retrieve the IP/Port pairs of a SOCKET to compare to the active connection you are interested in, without injecting remote getsockname()/getpeername() calls into the owning process of the SOCKET).
Once you have found the SOCKET handle you want, you can then close it by using DuplicateHandle() with the DUPLICATE_CLOSE_SOURCE flag 1.
1: This is how the "Close Handle" feature in Process Explorer works.
Since I'm using C#, I cannot PInvoke SetTcpEntry, even as administrator with an app.manifest file, it always sends a 317 error. So I created a C++ .exe to close a comma separated list of ipv4 addresses on the command line using SetTcpEntry, works fine even without an app.manifest file. That solves kicking ipv4 connections.
I tried using the get handles approach with NtQuerySystemInformation but never could get it working quite right, and it is a private mostly undocumented API and seems unsafe to use.
So, for ipv6, I am using windivert and injecting RST flag to ipv6 packets with certain ip addresses. It is as simple as setting the RST flag of an incoming packet before sending it on through with windivert. The downside is, if the client never sends another packet, the ipv6 socket still stays open indefinitely.
Perhaps someday Microsoft will add a SetTcpEntry6 function, but until then this appears to be the only realistic way.
UPDATE 2022-05-01, found this gem at https://www.x86matthew.com/view_post?id=settcpentry6

Packet modification for interception and redirection

I have been trying to find some way of redirecting outbound TCP packets under windows.
from from : https://github.com/basil00/Divert/blob/master/doc/windivert.html
"The WinDivert driver is automatically (and silently) installed on demand whenever
your application calls WinDivertOpen(). The calling application must have Administrator privileges."
Am a newbie in windows service programming. I want my Windows service to call the function WinDivertOpen().
Can someone just give a lead sample on how to go about it.
Thanks

how to originate two applications from fs_cli

Please answer this interesting question, I want to make two applications communicate with each other in free switch without a sip user, I have tried following things on fs_cli
originate user/1001 &bridge(Sofia/internal/1789)
user is able to communicate with the application
originate Sofia/internal/1235 &bridge(Sofia/internal/1789)
but this is throwing error that "cannot blind transfer 1235";
I noticed that by default a sip call is originated with caller id:<00000000> and transferring call to sip user in first case but unable to transfer to dial plan in second case please help me
Loopback is for you, create an extension / dialplan with one application and reload the dialplan, and then at fs_cli you can use loopback in originate to dial that application and at the other end enter second application, that's all
https://wiki.freeswitch.org/wiki/Loopback_endpoint

How to configure the path for the UDP on the UNIX domain socket?

I am new to socket programming. I'm tring to establish an UNIX domain socket with DATAGRAM. I look up the information about the configuration of sun_path in struct sockaddr_un for a while, seems like there are not enough sources to help me.
I created 3 files, unix_socket.c (provides an interface for socket connection), udp_server.c and udp_client.c, all are located in the directory "/home/Socket".
When I set the sun_path as "home/Socket", the server side always generates an error "Address already in use".
I also tried using "localSocket" and "echo_socket", but the client side always generates an error "No such file or directory".
I have no idea what's going on. Could anybody help me fix it? Really appreciate.
Thank you very much
The /home/Socket is already a folder, so it cannot be overwritten by a UNIX socket (think of it as a sort of a special file). Try another path like /home/Socket/mysocket.
You should also check out the bind(2) manpage and the example therein.

How to get the plugged/unplugged cable state

I know about the IsNetworkAlive function from the Windows API but IsNetworkAlive returns false until there's any network activity.
That is, if you start your computer and test connectivity it will return false. If you then ping another computer (or recieve a ping or any network activity from another computer) then it will start returning true.
Is there any alternative or does anyone know a workaround for this?
Things I've tried so far:
Ping to the local host (no go as there isn't really any network activity)
Ping to the local address (the same as before)
Note: I know there's another question very similar to this one, but my problem here is with IsNetworkAlive behaviour
The WinInet functions should meet your needs. Of particular interest is the InternetGetConnectedState function.
Maybe this is what you want: Check network connection status using C#.net?
(It use InternetGetConnectedState WinInet function)
Consider using
NetworkChange Class
The Connection Monitor Application Block

Resources