Click here to Skip to main content
15,881,588 members
Articles / Desktop Programming / MFC

The Ultimate TCP/IP Home Page

Rate me:
Please Sign up or sign in to vote.
4.98/5 (77 votes)
25 Aug 2007CPOL13 min read 2.5M   45.4K   267  
Ultimate TCP-IP is now Open Source
// Monitor.cpp : Defines the entry point for the console application.
//
// This little program just waits for data on port 9999.  

#include "stdafx.h"
#include "..\UDP_Client.h"

#pragma warning (push)
#pragma warning (disable : 4702)
// v4.2 this caused an 'unreachable code' warning at the return statement
int main(int /* argc */, char* /* argv[] */)
{
    // create a UDP_Client object
    CUDP_Client monitor;

    // bind to local port 9999.  Clients will need this number
    monitor.Open(9999);

    char buffer[256];
    int len;

	for(;;) {
        if(monitor.IsDataWaiting()) {
             len = 256;
             monitor.Read(buffer, len);
             buffer[len] = 0;
             if( 0 < len) {
                 printf("%d bytes received from %s ==>\n%s\n", len, monitor.GetRemoteAddress(), buffer);
             }
        }
    }
	return 0;
}
#pragma warning (pop)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
This is a Organisation

476 members

Comments and Discussions