A single UDP port in a multithreaded server

I'm trying to write a server application that creates a thread for every client. The server/client communication is a combination of TCP and UDP, and I want to use a fixed TCP/UDP port on the server side to make it easier to use behind NAT routers. Here's a summary of what I have done and what I want to achieve:
- The server creates a TCP and UDP channel (I'm using the NIO interface) on the specified ports
- The server waits for incoming clients by calling accept() on the TCP channel
- The server creates a new thread for the new client, and gives the TCP and UDP channels as arguments
- The client informs the server about its UDP port over the TCP connection
- The new server thread connect()s the UDP channel to the IP:port pair received over the TCP connection
I believed that connecting the UDP socket to the IP:port of the client in each thread would make it possible to use a single UDP port for the multithreaded application, but it seems that the connect() call affects the parent thread as well. The next client that tries to connect() gets a "Connect already invoked" error. I tried calling clone() on the UDP channel argument I passed to the new thread, but was not allowed to call clone() because it's protected.
Can someone tell me if what I'm trying to do is possible, and if so, how to achieve it?

Peter__Lawrey wrote:It sounds like you want to bind a UDP socket to a listening port and the sender as well. So you can have a thread per sending IP:port. (Not sure why you would want to...)
To my knowledge you can only bind a socket based on the listening port. You could have a dispatcher thread which passes these packets to the thread for that sender.
To me, client/server means a request/response based interaction with a request from the client and the response from the server back to the client. This interaction is typically point to point and lossless.-I wanted one thread per client because it's the simplest thing to implement. For example, I don't have to create data structures for storing state information for each individual client (e.g., bitrate, block size, duration, etc), since each thread has only one single client. Still, I don't want to use hacks like having a dispatcher thread, so if it is correct that UDP ports can't be used in the same way as TCP ports, I guess I'll just have to implement the server as a single-threaded process. :(
As for client/server, a better description would be master/slave (and that's what I'm using in my program), but I thought I'd make it simple and use the more common client/server terms in this thread since it doesn't matter for the question I'm asking.

Similar Messages

  • Anybody know what tcp or udp port # is used by Server Monitor?

    Hi everyone. I've been lookin' all over ****'s half-acre to find out what port # is required for Server Monitor with no luck. Sure, I can access the local IP address on the LAN, but for LOM to be truly useful...I need to access from WAN. Since my public IP takes me direct to the server itself (and other ports on that ip do other things), I really need to know what port # is used to forward Server Monitor traffic. Anyone?
    Thanks!
    Ed

    Ed LaComb-
    I do have this link to well known TCP and UDP ports used by Apple software products.
    I am fairly certain the answer lies within.
    Luck-
    -DaddyPaycheck

  • Is it dangerous if I expose UDP 1434 port of SQL 2008R2 server in Azure VM to the Internet ?

    I am setting up client/server Application running on SQL2008 server on Azure VM.
    Is it dangerous if I  expose UDP 1434 port of SQL 2008R2 server in Azure VM  to the Internet ?

    I do not get your answer exactly , but you mean "That is a much bigger issue from a security perspective." this is dangerous to expose SQL server connection port to the Internet ?
    Application uses named SQL instance , so it needs UDP 1434 port to connect to SQL server.
    Exposing any server to a network is dangerous.  Exposing a server to the public internet is more risky than connecting to a private network.  You cannot eliminate risk but it can be mitigated.
    An inherent risk with exposing the SQL Server port is that any client with network connectivity can then try to compromise security, commonly with a dictionary attack.  A malicious user can then gain access to the database limited only by
    the compromised account security context.
    There are several steps you can take to mitigate this risk.  To name a few, allow only trusted IP addresses through the firewall.  Run only those services actually needed.  Expose only those ports needed.  Rename the sa login. 
    Assign strong passwords to all accounts.  Keep all software up-to-date with security patches.  Use a service layer to access database services instead of directly from front-end clients.
    In your case, you can hard-code the named instance port in connection strings instead of using the SQL Browser service.  Your connection strings do not need to specify the instance name with this technique and UDP 1434 is not needed for connectivity. 
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • HT4814 TCP and UDP ports on router firewall to allow server to server administration running mavericks and server app 3.0?

    What TCP or UDP ports do I need to open on my router firewall to allow server to server administration running maverics and server app 3.0?

    Also you may want to open tcp port 625 so that you can update the server's OD master.
    More info can be found here: http://support.apple.com/kb/ts1629  Well known TCP/UDP ports used by Apple Products.
    HTH
    - Leland

  • Application by using more than 65535 UDP ports

    Hello all!
    I'm now implementing a device simulator in VC++ to performance a load test to our server application. I need to simulate a huge number of devices to communicate with this server via UDP, each device shall have its own UDP port exclusive during the
    simulation.
    Since there are maximal 65536 ports pro IP address and from 0 to 1024 are reserved by OS, theoretically I have 64511 free ports for my Simulator application, considering some ports are required by some services/applications, the free port number may a little
    fewer, I'm assuming this number is 60000. According to our software requirement, I can't reach the required simulating device amount under this port limitation.
    If I'm right, if one computer has more IPs, I shall have more than 60000 free ports. My simulator runs under Windows Server 2008, 2 physical network adapters and I used following command to change the dynamic UDP port range to get 60000 UDP ports:
          netsh interface ipv4 set dynamicportrange protocol=udp startport=3000 numberofports=60000
    My questions are:
    1. Is this setting globally available or for each IP address?
       I tried to set the parameter "numberofports" to 120000 but it didn't work.
    2. Shall I set for each IP address separately a UDP port range?
    3. If this setting is for each IP addres available, I have following problem:
       For two IP address, I could bind 60000 ports in total to 60000 UDP sockets, e.g IP1 20000 ports and IP2 40000 ports, or IP1 40000 ports and IP2 20000 ports. That means I can still use maximal 60000 UDP ports.
    Unfortunately, I can't find any reference about this topic in Internet, does anyone have my similar situation?
    Thank you in advance to teach me a solution!

    " I need so many UDP ports because our product has "state", and our Server application maintains connection sessions for each connected device."
    Couldn't you add some information to the datagrams that identify the state? That may require less resources than creating a zillion of sockets. Though I suppose that using a single socket would lead to serialization and that will hurt scaling...
    "How much memory does one socket need? I didn't think about this topic....."
    Hmm, memory is need for the socket data structures and buffers. Probably a few kilobytes. Let's do a test and see what happens:
    #include <winsock2.h>
    #include <cstdio>
    #pragma comment(lib, "ws2_32.lib")
    DWORD WINAPI ServerThread(LPVOID addr) {
    SOCKET sk = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if (sk == INVALID_SOCKET) {
    printf("socket failed\n");
    return 1;
    int err = bind(sk, static_cast<sockaddr *>(addr), sizeof(sockaddr_in));
    if (err != 0) {
    printf("bind failed\n");
    return 1;
    char buffer[256];
    sockaddr_in from;
    int fromLen = sizeof(from);
    for (;;) {
    int length = recvfrom(sk, buffer, 256, 0, reinterpret_cast<sockaddr *>(&from), &fromLen);
    printf("got %d bytes from %s:%d\n", length, inet_ntoa(from.sin_addr), htons(from.sin_port));
    int main() {
    WSADATA wsaData;
    int err = WSAStartup(MAKEWORD(2, 2), &wsaData);
    sockaddr_in to;
    to.sin_family = AF_INET;
    to.sin_port = htons(4242);
    to.sin_addr.S_un.S_addr = inet_addr("192.168.1.68");
    CreateThread(nullptr, 0, ServerThread, &to, 0, nullptr);
    const char *addrs[] { "192.168.1.40", "192.168.1.41", "192.168.1.42", "192.168.1.43" };
    SOCKET sockets[_countof(addrs)][30000];
    sockaddr_in from;
    from.sin_family = AF_INET;
    int count = 0;
    for (int i = 0; i < _countof(addrs); i++) {
    from.sin_addr.S_un.S_addr = inet_addr(addrs[i]);
    for (int j = 0; j < _countof(sockets[i]); j++) {
    SOCKET sk = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    from.sin_port = htons(65535 - j);
    err = bind(sk, reinterpret_cast<sockaddr *>(&from), sizeof(from));
    if (err != 0) {
    printf("bind failed while creating socket %d on %s:%d\n", count, addrs[i], 65535 - j);
    closesocket(sk);
    sk = INVALID_SOCKET;
    else {
    count++;
    sockets[i][j] = sk;
    printf("created %d sockets\n", count);
    char buffer[256];
    for (int i = 0; i < _countof(sockets); i++) {
    for (int j = 0; j < _countof(sockets[i]); j++) {
    if (sockets[i][j] != INVALID_SOCKET)
    err = sendto(sockets[i][j], buffer, 256, 0, reinterpret_cast<sockaddr *>(&to), sizeof(to));
    This creates almost 120000 sockets on my machine (Win 8.1). All the 192.168.1.x addresses are on the same network adapter, 4 of them are used for "clients" and 1 for the "server". Clients have ports in the range 35535 - 65535 so you get
    around 30000 sockets per address (a few ports are in use so you won't get exactly 30000 unless you adjust the code).
    When the program starts the kernel non paged pool jumps from ~50MB to ~200MB. That means around 1.3KBytes per socket.
    @Joel Engineer: "The windows operating system can only have one IP per Computer name and a computer can only have one name..."
    You're delusional.

  • Open udp port on Wireless Network

    I have a WLC2106 with 6 APs model 1240AG. An application uses port 11050 UDP for license management. The client send a broadcast on this port looking by the server, because this information is NOT passing through, the connection can't be established. With the original network (3com), there is no any problem but with Cisco network, this particular port appears to be closed. How can I confirm the AP is blocking this port? How can I open it? I tried with an ACL but the problem was not fixed.
    thanks in advance.

    Eric:
    Thanks so much for your support. Finally I have the application working.
    I found the problem was not with the UDP port alone, the problem was with all broadcast (your tips give me ligth).
    Besides the "Broadcasting Forwarding" option I changed the "Ethernet Multicast Mode" to Multicast.
    The key was this paragraph in the release notes:
    Re-enable Broadcast after Upgrading to Release 4.0.206.0
    In software releases 4.0.179.0 and earlier, broadcast and multicast forwarding were both controlled with a single global flag that enabled multicast. Beginning with software release 4.0.206.0, these functions were broken into separate configuration flags: one that controls broadcast and one that controls non-broadcast multicast. If you have multicast enabled in software releases 4.0.179.0 and earlier, the broadcast flag is left disabled after upgrading to software release 4.0.206.0. As a result, some applications that rely on broadcast do not work after the upgrade.
    After you upgrade to software release 4.0.206.0, use this CLI command to re-enable broadcast:
    config network broadcast enable
    When re-enabled, broadcast uses the multicast mode configured on the controller.
    To be honest I am not very clear how the multicast mode is related with the problem, but now I can see all the broadcast messages passing through wireless network.
    Thanks a lot
    Daniel Escalante.

  • Identify Ports for AD - External UDP port scanner

    Greetings all,
    I am trying to figure out which UDP port is alarming on the "AD - External UDP port scanners (13005)" signature. By default, the signature is set to summarize which looks something like this "NumDestIps=100; currentTHreshold=100. protocol=1".
    From the "Protocol = 1" line I am assuming all scanning is hitting up on a single destination protocol - I need to know which protocol / port number.
    I've already attempted to turn on "log attacker, pair, and victim" packets. Verbose is not an option for this signature. I have also tried changing alert Frequency to "fire all" or just uncheck the "Summary Mode" box. None of this tells me the destination/victim port. I do see under a protocol field "ICMP" but i don't believe that pertains to the source port. Any ideas on how I might find this information?

    TCP/445 is used by Microsoft file sharing (CIFS), and by default that port is opened on all Microsoft PC basically to allow file sharing.
    If you open up DOS prompt, and type: netstat -na, you would see that your PC is by default listening on TCP/445.
    Here is more information on Microsoft-DS (TCP/445):
    http://www.linklogger.com/TCP445.htm
    http://en.wikipedia.org/wiki/Server_Message_Block
    So it really depends on your corporate security policy, whether to allow file sharing or not within the network. IPS is picking that up because it is an easier way of exploiting a PC since the port is opened by default.

  • Need help w/ setting up ports to run a server for America's Army

    Need help w/ setting up ports to run a server for America's Army. I read wat u need to change the ports but i dont understand wat to put. here is wat the site says
    Q: How do I run my own server?
    A: Quick and dirty server info:
    1. Edit RunServer.bat to change the map.
    2. Run RunServer.bat
    Or:
    server.exe LAN MAPNAME.aao (Host a LAN game)
    server.exe global MAPNAME.aao (Host a Public game)
    Also: When you create a server setup and want to allow other users to join your server, you need make sure the following ports are open for outgoing and incoming traffic in your firewall: 1716 (UDP), 1717 (UDP), 20025-20045 (TCP), and 20047 (TCP). Failure to open these ports will prevent the server from accepting connections from other players or prevent other players from being able to see your server online.
    There are several settings that also need to be defined in your server configuration INI file (in the Windows version, these files are located in “My Documents\America’s Army Server Settings\{settings file name}.ini”).
    [Engine.GameEngine]
    ServerActors=Andromeda.AndromedaMBS
    [Andromeda.Andromeda]
    GameServerIp=
    Make sure that you set the actual IP address of the America’s Army Server under GameServerIp= (for example, “GameServerIp=000.000.000.000”). The supplied address must be your actual internet IP address, if this is left blank or you supply the IP address for your internal network (such as 192.168.0.x), your server will not be able to accept connections from the internet.
    If your server.ini file contains the setting shown below, please change the QueryPort setting to 20025. This setting can also be removed, as the default setting is port 20025.
    [Andromeda.AndromedaMBS]
    QueryPort=20025
    Punkbuster user fix correction.
    If [Engine.GameEngine] block has been changed to read as below:
    [Engine.GameEngine]
    ServerActors=IPDrv.AndromedaMBS
    Please add the following block to your INI file:
    [IpDrv.AndromedaMBS]
    QueryPort=20025
    (Last Updated: 2006-04-20)

    Your images are not stored in the catalog. They are stored in folders on your computer. If you imported images that were already on your computer using the "Add" Option they are still in that same folder. If you imported images from your camera then they are in the folders that you specified when you imported. The catalog points to those images wherever they are located, and records all of the adjustments that you make to the image. When you send an image to Photoshop for further editing and save that image in Photoshop, it is normally saved back in the same folder as the original image.
    Images are not "saved" in Lightroom. The basic default workflow in Lightroom is to store all of the adjustments in the catalog, leaving the original image completely unmodified. The catalog becomes the central controlling mechanism. It is a database that contains pointers to where the images are located and a record of all adjustments made to those images using Lightroom. Properly managed, you only have those original master files and secondary files for the ones that you have sent to Photoshop for further adjustment. When you want to provide a copy for someone else, you use the export dialogue for that purpose. I often export JPEG images to share with others or to post on the web. After I have usedthe JPEG for its intended purpose I delete it.

  • UDP PORT 445 Not listed in System Process

    Hi! Can you help me? I need the UDP PORT 445 listed on SYSTEM Process. 
    I open UDP PORT 445 on Firewall (WSBS 2011), but in Syshelp (symatech validation too) the result is:
    Title: One or more network services, ports, protocols or associated processes may need attention
    Product: Backup Exec Server
    Status: Warning
    Details:
    Warning SYSTEM's UDP port 445 is not open or listening.
    Warning Port is not open or listening.
    UDP Process: System
    Ok SYSTEM is the correct process for UDP port 137
    Ok Port 137 with protocol UDP is open on the following IP addresses: - 25.54.28.213
    - 169.254.41.25
    - 169.254.244.222
    - 192.168.0.6
    - 192.168.1.2
    Ok Process System has port 137 with protocol UDP open.
    Ok Process System has port 137 with protocol UDP open.
    Ok Process System has port 137 with protocol UDP open.
    Ok Process System has port 137 with protocol UDP open.
    Ok Process System has port 137 with protocol UDP open.
    Information Network service name not defined. Test skipped.
    Information Default settings - Network Service Name: netbios-ns Port: 137 Protocol: UDP Process: System
    Ok SYSTEM is the correct process for UDP port 138
    Ok Port 138 with protocol UDP is open on the following IP addresses: - 25.54.28.213
    - 169.254.41.25
    - 169.254.244.222
    - 192.168.0.6
    - 192.168.1.2
    Ok Process System has port 138 with protocol UDP open.
    Ok Process System has port 138 with protocol UDP open.
    Ok Process System has port 138 with protocol UDP open.
    Ok Process System has port 138 with protocol UDP open.
    Ok Process System has port 138 with protocol UDP open.
    Information Network service name not defined. Test skipped.
    Information Default settings - Network Service Name: netbios-dgm Port: 138 Protocol: UDP Process: System
    Ok SYSTEM is the correct process for TCP port 445
    Ok Port 445 with protocol TCP is open on the following IP addresses: - 0.0.0.0
    Ok Process System has port 445 with protocol TCP open.
    Information Network service name not defined. Test skipped.
    Information Default settings - Network Service Name: microsoft-ds Port: 445 Protocol: TCP Process: System

    Hi,
    à
    I need the UDP PORT 445 listed on SYSTEM Process.
    à
    Warning SYSTEM's UDP port 445 is not open or listening.
    Based on your description, I’m a little confused with this issue. Please run following commands with administrator
    permission and monitor the result. Would you please check and confirm whether any process listened the UDP port 445?
    netstat –ab
    netstat -a | find /i "445"
    In addition, I noticed that you use Syshelp (Symantec validation tool) to check. I suggest that you would post
    the warning message in Symantec Forum and confirm this issue. I believe we will get a better assistance there.
    If anything I misunderstand, please don’t hesitate to let me know.
    Hope this helps.
    Best regards,
    Justin Gu

  • MultiThreaded Server and Client connections query.

    I have written a MultiThreaded Server to accept incoming client requests.
    Multiple clients can connnect to this server and have a conversation.
    I invoke the 'MultiServer' from the command line and then invoke 3 clients
    from the command line.('Client').
    c:> java MultiServer
    c:> java Client
    c:> java Client
    c:> java Client
    All the 3 clients now run in their own thread and send messages
    to the server.
    The problem I am facing is this:
    When client1 connects to the server and sends a message to the server (with the server responding)
    it works fine.Both Server and Client can exchange messages.
    When client2 connects to the server and sends a message and when the server
    responds with a message,the message does NOT go to client2,but goes to Client1
    As Clients have their own thread to run,shouldnt the messages also be delivered to
    individual clients
    Am I missing something?
    My Code
    public class MultiServer {
        public static void main(String[] args) throws IOException {
            ServerSocket serverSocket = null;
            boolean listening = true;
            try {
                serverSocket = new ServerSocket(4444);
                System.out.println("MultiServer listening on Port 4444");
            } catch (IOException e) {
                System.err.println("Could not listen on port: 4444.");
                System.exit(-1);
            // Indefinite Loop.
            while (listening)
             new MultiServerThread(serverSocket.accept()).start();
            serverSocket.close();
    public class MultiServerThread extends Thread {
        private Socket socket = null;
        public MultiServerThread(Socket socket) {
         super("MultiServerThread");
         this.socket = socket;
        public void run() {
         try {
             PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
             BufferedReader in = new BufferedReader(
                            new InputStreamReader(
                            socket.getInputStream()));
               BufferedReader stdInFromServer = new BufferedReader(new InputStreamReader(System.in));
            String fromTheClient,fromServer;
               fromServer = "Hi Client,How u doing? ";
            // Send a message from the Server.
               out.println(fromServer);
                while ((fromTheClient = in.readLine()) != null) {
                 if (fromTheClient.equals("ByeServer"))
                 break;
                 // Display message received from Client.
                 System.out.print("Client Response : ");
              System.out.println(fromTheClient);
                 // Input reply from the Server.
                 fromServer = stdInFromServer.readLine();
                 out.println(fromServer);
                 if (fromServer.equals("Bye."))
                    break;
             out.close();
             in.close();
             socket.close();
         } catch (IOException e) {
             e.printStackTrace();
    Client Code
    ===========
    public class Client {
        public static void main(String[] args) throws IOException {
            Socket kkSocket = null;
            PrintWriter out = null;
            BufferedReader in = null;
            try {
                kkSocket = new Socket("localhost", 4444);
                out = new PrintWriter(kkSocket.getOutputStream(), true);
                in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
            } catch (UnknownHostException e) {
                System.err.println("Don't know about host: localhost.");
                System.exit(1);
            } catch (IOException e) {
                System.err.println("Couldn't get I/O for the connection to: localhost.");
                System.exit(1);
            BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
            String fromServer;
            String fromUser;
            while ((fromServer = in.readLine()) != null) {
                System.out.println("Server: " + fromServer);
                if (fromServer.equals("Bye."))
                    break;
                    fromUser = stdIn.readLine();
             if (fromUser != null) {
                    out.println(fromUser);
            out.close();
            in.close();
            stdIn.close();
            kkSocket.close();
    }

    Taking standard input for multiple threads from one console is quite unpredictable. I think the first client thread is waiting for input when you connect the second. You type something into your server window and since the first thread was waiting for input, it takes the input and sends it to client 1.

  • URGENT:Handle multiple connection in a multithreaded server.

    I hava a multithreaded server where it can handle multiple connection.
    The program works in this way. First, it will wait for connection. Once it accepts a connection, it will pass the socket to a thread class which will in turn process the connection. Then, the server will go back to the infinite loop to wait for new connection.
    Since I am not very familiar on using thread, I would like to post the following questions:
    1) Let say that my server can handle multiple connections. This is to cater for the different requests from the client. For instance, the client may make one connection for chatting and another connection for sending file(something like we have in Yahoo Messanger). So, at the server side, how can I differentiate between the connection for CHAT and the connection for SEND FILE so that I can handle the requests separately. It means I can save the file sent from client and display the chat message in the JTextArea?
    2) How can I stop the server, clean up the thread and start the server again for waiting new connection? Currently, I can just start my server once.
    For reference,following are parts of my program:
    public void listenSocket(){
    try{
    server = new ServerSocket(5000);
    } catch(IOException e) {
    System.out.println("Failed to listen on port 5000");
    System.exit(0);
    try{
    while(true){
    server1frame sframe=null;
    ChatHandler handler;
    handler = new ChatHandler(sframe,server.accept(),jTextArea1,jTextField1,jFileChooser1);
    handler.start();
    } catch(IOException e) {
    System.out.println("Accept failed:5000");
    System.exit(0);
    //to close the connection as the final steps before program exit.
    } finally {
    try{
    server.close();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    public void run() {
    out.println("Connection Established");
    out.flush();
    try {
    String line;
         while(!(line =in.readLine()).equalsIgnoreCase("QUIT")) {
    if(line.startsWith("CLIENT"))
    jTextArea1.append("\n"+line);
    else if(line.startsWith("Connecting")) {
    jTextArea1.append("\n"+line);
    else if (line.startsWith("Finish")) {
    JOptionPane.showMessageDialog(sframe,"File has finished downloading",
    "File Download Complete",JOptionPane.INFORMATION_MESSAGE);
    else {
    BufferedWriter fout = new BufferedWriter(
    new FileWriter("e:/num1.txt",true));
    fout.write(line);
    fout.newLine();
    fout.flush(); }
         } catch(IOException ioe) {
         ioe.printStackTrace();
         } finally {
         try {
              in.close();
              socket.close();
         } catch(IOException ioe){
    System.out.println("Fail to close connection.");

    1) Let say that my server can handle multiple
    connections. This is to cater for the different
    requests from the client. For instance, the client may
    make one connection for chatting and another
    connection for sending file(something like we have in
    Yahoo Messanger). So, at the server side, how can I
    differentiate between the connection for CHAT and the
    connection for SEND FILE so that I can handle the
    requests separately. It means I can save the file sent
    from client and display the chat message in the
    JTextArea?Either your server listens on two different ports for two different protocolls, (then you would a server thread for each port) or you accept connections for both protocolls on both ports, and have the client state what protocoll it is using :
    eg:
    accept Connection - start new Thread - read first line - depending on protocoll pass protocoll object (CHAT, FTP) to run method
    There is an example for a simple protocoll at : http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
    2) How can I stop the server, clean up the thread and
    start the server again for waiting new connection?
    Currently, I can just start my server once.You normally start servers only once. It should then be up and listening for it's entire lifetime. Restarting a server should only be needed if it hangs or crashes.

  • Monitor a UDP port

    Hi,
    I could find a solution for my problem. I need to monitor a UDP port.
    For the TCP ports i'm using MP template TCP Port, but for the UDP i don't find any tool.
    My question is. It's possible to monitor UPD ports in SCOM 2012 R2? If yes, how?
    Thank you,
    Rui 

    Hi Rui,
    I have found a possibility to do this. Hope you understand this and it is helpful. This is a two step process but guess will definitely server the purpose.
    Scope: We will be running a tool which will monitor a port (TCP or UDP) for a specific host / IP and will throw a log file.
    SCOM will monitor the log file and will throw a alert if the log file contains the string NOT LISTENING (Port not working or unable to open the port) which the program will create the log with the results.
    First download the program named: PortQry Command Line Port Scanner Version 2.0 from microsoft using the below link. It is a command line tool.
    http://www.microsoft.com/en-in/download/details.aspx?id=17148
    Run it using by making a batch file or powershell script using task scheduler as per your time requirement (Every 5 min or 1Hr).
    Use this command to monitor a ip / hostname and its port with TCP or UDP.
    I have pasted the command file of the program in C:\Port_checker directory so i am using the below syntax
    C:\Port_checker\PortQry.exe -N 192.168.1.1 -e 5723 -p UDP -l C:\Port_checker\Result.log /y
    -N = Hostname / FQDN of agent or Ip address
    -E = Port # what you want to monitor
    -P = Protocol (TCP or UDP)
    -L = Generate log on the following location and name
    /Y = To replace the existing log file name to fresh one without prompt.
    The result in the log file will be as follows:
    ============================
    For successful port open:
    PortQry Version 2.0 Log File
    System Date: Tue Oct 07 09:42:32 2014
    Command run:
     C:\PortQryV2\PortQry.exe -N 192.168.1.1 -e 5723 -p UDP -l C:\Portqryv2\Result.log /y
    Local computer name:
     192.168.1.2
    Querying target system called:
     192.168.1.1
    Attempting to resolve name to IP address...
    Name resolved to 192.168.1.1
    querying...
    UDP port 5723 (unknown service): LISTENING
    ========= end of log file ========= 
      PortQry developed by Tim Rains
    For failure port open:
    PortQry Version 2.0 Log File
    System Date: Tue Oct 07 09:42:32 2014
    Command run:
     C:\PortQryV2\PortQry.exe -N 192.168.1.1 -e 5723 -p UDP -l C:\Portqryv2\Result.log /y
    Local computer name:
     192.168.1.2
    Querying target system called:
     192.168.1.1
    Attempting to resolve name to IP address...
    Name resolved to 192.168.1.1
    querying...
    UDP port 5723 (unknown service): NOT LISTENING
    ========= end of log file ========= 
      PortQry developed by Tim Rains
    Now as per the above results NOT LISTENING Port is blocked or is not opened and LISTENING
    means working or port is opened.
    So now using SCOM you will monitor the log file Result.log
    in the location C:\Port_checker\ saying if NOT LISTENING
    comes in the log file throw me a alert in SCOM consle or via email.
    To configure that alert you need to create a Generic text log alerting Rule which will throw a alert if any thing added in that log which is not to be added and if it is added like NOT LISTENING
    then it will throw a alert.
    Refer this link on how to open a Generic text log alerting Rule.
    http://blogs.technet.com/b/kevinholman/archive/2009/06/20/using-a-generic-text-log-rule-to-monitor-an-ascii-text-file-even-when-the-file-is-a-unc-path.aspx
    Gautam.75801

  • Multithread server with futureTask

    i want to write a multithread server that prints the message received from a client in reverse order i have problems with getting the message from a client and passing that to futureTask
    this is my futureTaskCallback
    class FutureTaskCallback<V> extends FutureTask<V> {
    public FutureTaskCallback(Callable<V> callable) {
    super(callable);
    public void done() {
    String result = "Wynik: ";
    if (isCancelled()) result += "Cancelled.";
    else try {
    result += get();
    } catch(Exception exc) {
    result += exc.toString();
    JOptionPane.showMessageDialog(null, result);
    and mycallable
    public class MyCallable implements Callable
    String toReverse;
    public MyCallable(String s){toReverse=s;}
    public String call () throws java.io.IOException, InterruptedException {
         StringBuffer out = new StringBuffer();
         ////ClientWorker w;
    /// w = new ClientWorker(server.accept(), textField);
    /// Thread t = new Thread(w);
    //// t.start();
    //////toReverse=textField.getText();
         ///System.out.println(toReverse);
    if (toReverse == null || toReverse.trim().equals(""))
    throw new IllegalArgumentException("Set string to reverse");
    ///if (t.isInterrupted()) return null;
    char[] org = toReverse.toCharArray();
    //// if (t.isInterrupted()) return null;
    for (int i = org.length-1; i>=0; i--) {
    Thread.sleep(500);
    out.append(org);
    ////if (t.isInterrupted()) return null;
    ///textField.setText(out.toString());
    ////if (t.isInterrupted()) return null;
         ///////Thread t = Thread.currentThread();
    return out.toString();
    i want to pass the message received from a client to mycallable then to server so it can print the output
    how to do that ?
    thank you
    regards

    Here's a primitive example:
    import java.net.*;
    import java.util.concurrent.*;
    import java.io.*;
    import javax.swing.*;
    public class RevServer{
      ServerSocket ss;
      boolean go;
      public RevServer(int port){
        try{
          ss = new ServerSocket(port);
        catch (Exception e){
          e.printStackTrace();
        go = true;
      public void runServer(){
        try{
          while (go){
            Socket s = ss.accept();
            System.out.println("...client connected");
            service(s);
          ss.close();
        catch (Exception e){
          e.printStackTrace();
      void service(Socket s){
        Thread t = new Thread(new ClientHandler(s));
        t.start();
      public static void main(String[] args){
        RevServer rs = new RevServer(9999);
        rs.runServer();
    class ClientHandler implements Runnable{
      Socket sct;
      public ClientHandler(Socket s){
        sct = s;
      public void run(){
        try{
          BufferedReader br
           = new BufferedReader(new InputStreamReader(sct.getInputStream()));
          String msg = br.readLine();
          FutureTaskCallback<String> ftc
           = new FutureTaskCallback<String>(new MyCallable(msg));
          new Thread(ftc).start();
          PrintWriter pw = new PrintWriter(sct.getOutputStream(), true);
          pw.println(ftc.get());
          sct.close();
        catch (Exception e){
          e.printStackTrace();
    class FutureTaskCallback<V> extends FutureTask<V> {
      public FutureTaskCallback(Callable<V> callable) {
        super(callable);
      public void done() {
        String result = "Wynik: ";
        if (isCancelled()){
         result += "Cancelled.";
        else{
          try {
            result += get();
          catch(Exception exc) {
            result += exc.toString();
        JOptionPane.showMessageDialog(null, result);
    class MyCallable implements Callable<String>{
      String toReverse;
      public MyCallable(String s){
        toReverse = s;
      public String call() throws java.io.IOException, InterruptedException {
        StringBuffer out = new StringBuffer();
        if (toReverse == null || toReverse.trim().equals("")){
          throw new IllegalArgumentException("Set string to reverse");
       char[] org = toReverse.toCharArray();
        for (int i = org.length - 1; i >= 0; i--) {
          Thread.sleep(500);
          out.append(org);
    return out.toString();
    import java.net.*;
    import java.io.*;
    public class RevClient{
    public static void main(String[] args) throws Exception{
    String str, rstr;
    str = "All you need is love";
    if (args.length > 0){
    str = args[0];
    Socket sc = new Socket("127.0.0.1", 9999);
    PrintWriter pw = new PrintWriter(sc.getOutputStream(), true);
    BufferedReader br
    = new BufferedReader(new InputStreamReader(sc.getInputStream()));
    pw.println(str);
    System.out.println("...wait a moment");
    rstr = br.readLine();
    System.out.println(rstr);
    sc.close();

  • How to unblock UDP ports from the firewall of the Time Capsule

    Hello i just bought a time capsule and i am trying am using it as a router. I am trying to use Shakespeer
    that is like a server where you share files within the University,it runs with Dtella. However, when y try to get online a message tells me that the firewall of the router is blocking the UDP ports needed....how do i unblock those UDP ports so i can get online?
    Here is the message:
    In order for Dtella to communicate properly, it needs to receive UDP traffic
    [19:14] <*Dtella> from the Internet. Dtella is currently listening on UDP port 4000, but the
    [19:14] <*Dtella> packets appear to be getting blocked, most likely by a firewall or a router. If
    [19:14] <*Dtella> this is the case, then you will have to configure your firewall or router to
    [19:14] <*Dtella> allow UDP traffic through on this port. You may tell Dtella to use a different
    [19:14] <*Dtella> port from now on by typing !UDP followed by a number.

    Hello albertoPeralta. Welcome to the Apple Discussions!
    To open ports on the Time Capsule, you would use the AirPort Utility to configure Port Mapping.
    AEBSn - Port Mapping Setup
    To setup port mapping on an 802.11n AirPort Extreme Base Station (AEBSn), either connect to the AEBSn's wireless network or temporarily connect directly, using an Ethernet cable, to one of the LAN port of the AEBSn, and then use the AirPort Utility, in Manual Setup, to make these settings:
    1. Reserve a DHCP-provided IP address for the Shakespeer host device.
    Internet > DHCP tab
    o On the DHCP tab, click the "+" (Add) button to enter DHCP Reservations.
    o Description: <enter the desired description of the host device>
    o Reserve address by: MAC Address
    o Click Continue.
    o MAC Address: <enter the MAC (what Apple calls Ethernet ID if you are using wired or AirPort ID if wireless) hardware address of the host computer>
    o IPv4 Address: <enter the desired IP address>
    o Click Done.
    2. Setup Port Mapping on the AEBSn.
    Advanced > Port Mapping tab
    o Click the "+" (Add) button
    o Public UDP Port(s): 4000
    o Private IP Address: <enter the IP address of the host server>
    o Private UDP Port(s): 4000
    o Click "Continue"

  • Forwarding UDP port for Remote Desktop Gateway

    What is the correct way to forward UDP 3391 port for RDG server?
    What direction should I choose for UDP port parameters? "Receive" or "Receive Send" or something else?

    Aurimas N, Were you able to get RemtoteFX working through TMG? I have the same issue whre I can not get UDP working with clients conneciting over the WAN.  Can you tell me specifically how you got this to work on your TMG?
    Thanks
    I am not sure how to check to be honest, on TMG I only see 443 port being used, and since it is remoteApp there is no connection indicator, or I don't know how to access it.

Maybe you are looking for

  • How can I set up a delayed analog trigger on PCI 6115 DAQ

    I have an S-Series PCI 6115 DAQ which I'm running with Labview. I'm using it to measure signals from an acoustic emission sensor and two force transducers. I'd like to set up a delayed analog trigger which will start acquisition on all three channels

  • Preserving time when importing from Photoshop Elements

    I have about 15K photos that I am moving from Photoshop Elements on Windows to Aperture. In Elements all my photos are in time order sequence plus the liberal use of tags. The tags work fine but the time sequence does not. Most photos have the date f

  • Arabic letters in Text object

    Arabic letters in Text object I want to create a web pages which has to show the mother language the user clicks. For eg. French, German, Arabic. If a particular language is selected then all web pages should be in that language. I want to know is it

  • Validate INPUT TEXT

    Hi there, Anybody can help me,just I have a page with 3 numeric field and I need to validate these field, the idea is accept only numeric input, how can I do this?

  • Sensorless control DC motor based on mathematic​al model

    Hi, I have DC motor, I put together mathematical model and transfer function of torque, speed and position PI control too. Can someone help me to implement it to real process? I need control real DC motor with H-bridge with sensorless method based on