Class DUDPClient

Inherits from:
Object
Declared in:
DUDPClient.h

Class Hierarchy

    Object
      |
      +---DUDPClient

Class Description

The DUDPClient class implements a number of methods for implementing an UDP client.

Example:
#include <stdio.h>
#include "ofc/DUDPClient.h"
#include "ofc/DSocketAddress.h"

int main(int argc, char *argv[])
{
  DInetSocketAddress *addr = [DInetSocketAddress new];
  DUDPClient         *clnt = [DUDPClient         new];
  DData              *data;

  [addr host :"localhost" :7000];

  printf("Open the client..\n");

  if ([clnt open :[addr family] :[DSocket protocol :"udp"]])
  {
    printf("Open connection to the server..\n");

    if ([clnt start :addr])
    {
      printf("Send request to the server..\n");

      data = [clnt doRequest :addr :"Hello" :5 :256];

      if (data != nil)
      {
        DText *str = [data toText];

        printf("Response from the server:%s.\n", [str cstring]);

        [str  free];
        [data free];
      }
      else
        printf("No data received from the server.\n");

      [clnt stop];
    }
    else
      printf("Cound not open connection to the server.\n");
  }
  else
    printf("Could not open the client.\n");

  [clnt free];                         // Cleanup
  [addr free];

  return 0;
}
Last modified:
11-Aug-2008 (DUDPClient.h)

Instance Variables

private DSocket *_local
the local socket
private int _sendFlag
the send flags (def. 0)
private int _recvFlag
the receive flags (def. 0)
private BOOL _started
is the client started ?

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0