views:

284

answers:

2

Platform: Windows 2003 R2, C#

I have an application that sends UDP messages to other instances of itself, running on the same computer and on other computers. This is working fine. But, on some computers, the listener cannot hear messages that other thread/process on the same computer has transmitted. The message is broadcast ok, and other machines on the network hear the message, but a listener on the same machine cannot hear the message.

The weird part is that this happens on SOME machines in my test environment, but not all.

Edit: All machine that fail have the Check Point VPN-1 Securemote client software installed. I took a machine that was working, installed the VPN client, and now it does not work. Note that I am not connected to any VPN hosts, I just have the client installed.

All machines have a single network adapter, subnet mask of 255.255.255.0, and IP address of 10.3.10.xxx.

Here is a test class that demonstrates the problem. The user types some text, and it gets sent to 10.3.10.255. On some machines, the ReceiveFrom returns, and on others it does not. I am calling Controller("10.3.10.255",33333)

public class Controller
{
    public Controller(IPAddress broadcastAddress, int port)
    {
         _broadcastAddress = broadcastAddress;
         _port = port;
    }

    public void Start()
    {
        Socket s = null;

        try
        {
             IPEndPoint _listenEndpoint = new IPEndPoint(IPAddress.Any, _port);
            _broadcastEndpoint = new IPEndPoint(_broadcastAddress, _port);

            s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 10);
            s.EnableBroadcast = true;
            s.Bind(_listenEndpoint);

            SocketState receiveState = new SocketState();
            receiveState.s = s;
            receiveState.buf = new byte[1024];

            EndPoint lep = (EndPoint)_broadcastEndpoint;

            s.BeginReceiveFrom(receiveState.buf, 0, receiveState.buf.Length, SocketFlags.None, ref lep, new AsyncCallback(OnReceive), receiveState);

            bool done = false;
            while (!done)
            {
                string msg = Console.In.ReadLine();
                byte[] msg_bytes = Encoding.ASCII.GetBytes(msg);

                if (msg_bytes.Length == 0)
                    done = true;
                else
                {
                    Console.Out.WriteLine("---> {0}", msg);
                    s.SendTo(msg_bytes, msg_bytes.Length, SocketFlags.None, new IPEndPoint(_broadcastAddress, _port));
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
        finally
        {
            if (s != null)
                s.Close();
        }
    }

    internal void OnReceive(IAsyncResult ar)
    {
        SocketState state = ar.AsyncState as SocketState;
        IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 0);
        EndPoint ep = (EndPoint)ipep;

        int nRead = state.s.EndReceiveFrom(ar, ref ep);

        IPEndPoint myipep = ep as IPEndPoint;

        Console.WriteLine("<--- {0} {1}", myipep.Address.ToString(), System.Text.Encoding.ASCII.GetString(state.buf, 0, nRead));

        EndPoint lep = (EndPoint)_broadcastEndpoint;
        state.s.BeginReceiveFrom(state.buf, 0, state.buf.Length, SocketFlags.None, ref lep, new AsyncCallback(OnReceive), state);
    }

    IPAddress _broadcastAddress;
    int _port = 0;
    IPEndPoint _broadcastEndpoint;
}

internal class SocketState
{
    internal Socket s;
    internal byte[] buf;
}
A: 

What does the Check Point VPN-1 Securemote client software do? It sounds like it might do some sort of firewalling in which case it would be blocking data coming in on the specified port.

1) If you can configure it to allow data through that port, then you should be good to go.

2) Another less likely option is that maybe it is listening on the port that you are trying to listen to in which case it is receiving the udp packet as opposed to your application. I would expect you app to throw an error though in that case.

Mark
It's VPN client software, for connecting to VPN hosts. But, it is currently not connected to any host.netstat -a shows that nobody has this port open. I also tried changing the port number, no affect.
David Chappelle
A: 

In the SecureClient settings (right click on the tray icon and select Settings), on the Security tab you can enable an option to "log all connections that are blocked by the desktop security policy".

You should then be able to see if that's indeed what is blocking your application - if it is, you'll have to get the default policy changed to allow your application. I'm not sure how to do that - I've never administered the server side of SecureRemote, but I'm sure Check Point can help you out if your network admins can't.

caf
This is the Securemote client - no firewall is installed. The SecureClient is the one with firewall functionality.
David Chappelle