/* * Copyright (C) 1994-1996, Michael S. Durkin & Tsoft. All Rights Reserved. * Please see legalese in README.1ST or contact us for details: * Contact: Mike Durkin mdurkin@tsoft.net (email preferred) * c/o Tsoft * P.O. Box 14897 * Berkeley, CA 94712 USA */ /* # sends numbered UDP datagrams to a remote host. # # Usage: # udp-send [-n ] # [-s ] # [-p ] # host # # defaults to 16, to 32 # and to 9870. # # Renaud Waldura # on Sep 18 16:51:24 1995 # converted to trumpet abi by Dan Kegel and Chris Thomas 6/7/1996 */ #include #include #include #include #include #include #define TRUE (1) #define FALSE (0) #define TIMEOUT 20 #define BUFLEN 512 static char inbuf[BUFLEN]; int datagrams_n = 16; int datagrams_size = 32; int port = 9870; static void print_usage( char *progname ) { printf( " Usage:\n" " %s [-n ]\n" " [-s ]\n" " [-p ]\n" " host\n", progname); } static int send_packets(char *hostname) { unsigned int send_handle; unsigned long dst_ip; unsigned dst_port; unsigned src_port; int n, i; int err; int namelen, inlen; // open a handle to send packets to port 9870 dst_ip = htonl(aton(hostname)); dst_port = 9870; src_port = 0; send_handle = tcpabi_udp_open(dst_ip, dst_port, src_port, UDP_OPEN_NORMAL, NULL); if (send_handle == NULL_HANDLE) { printf("error opening send_handle!\n"); return FALSE; } printf("send_handle opened!\n"); for (n = 1; n /*------------------------------------------------------------------------- Get a block of DOS memory. Return flat pointer to it, or NULL on failure. Also place segmented real mode pointer in *seg, *off, and protected mode selector in *sel. (The selector is only needed to free the memory, thanks to the flat memory model of DOS4G.) -------------------------------------------------------------------------*/ void *my_dos_malloc(size_t len, short *seg, short *off, short *sel) { union REGS regs; // Note: The DPMI service expects the number of paragraphs not bytes. regs.w.ax = (short) 0x0100; regs.w.bx = (len + 0xf) >> 4; int386(DPMI_INT, ®s, ®s); if (regs.w.cflag) { // Abort! Out of DOS memory! return NULL; } // Result is in AX:DX (seg:sel) *seg = regs.w.ax; *off = 0; *sel = regs.w.dx; return (void *) (regs.w.ax << 4); } #endif int main( int argc, char *argv[] ) { int i; int exitcode = 0; short selector; puts("udpsend test (for UDP ABI) -- Copyright (C) 1994, Michael S. Durkin"); if( argc == 1 ) { print_usage( argv[0] ); exit(1); } for (i = 1; i