Friday, September 29, 2006

UDP client

#include
#include
#include
#include
#include
#include
void error(char *);
int main(int argc, char *argv[])
{
int sock, length, n;
struct sockaddr_in server, from;
struct hostent *hp;
char buffer[256];
if (argc != 3) { printf("Usage: server port\n");
exit(1);
}
sock= socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) error("socket");
server.sin_family = AF_INET;
hp = gethostbyname(argv[1]);
if (hp==0) error("Unknown host");
bcopy((char *)hp->h_addr,(char *)&server.sin_addr,hp->h_length);
server.sin_port = htons(atoi(argv[2]));
length=sizeof(struct sockaddr_in);
printf("Please enter the message: ");
bzero(buffer,256);
fgets(buffer,255,stdin);
n=sendto(sock,buffer,strlen(buffer),0,&server,length);
if (n < 0) error("Sendto");
n = recvfrom(sock,buffer,256,0,&from, &length);
if (n < 0) error("recvfrom");
write(1,"Got an ack: ",12);
write(1,buffer,n);
}
void error(char *msg)
{
perror(msg);
exit(0);
}

1 Comments:

Blogger Anjul said...

IT4801 : COMPUTER PERIPHERALS AND INTERNET APPLIANCES

1. PC Hardware Overview: Motherboard: Motherboard components, Motherboard logic, BIOS : Hardware – BIOS – DOS Interaction.
Bus concept, I/O ports: I/O port Addresses, Serial ports, Parallel ports, Universal Serial Bus, IEEE1394.
Interrupts : Interrupt servicing, Interrupt types.
Input/Output Techniques: Programmed mode, Interrupt mode, DMA mode.
Device controllers: Functions of a Device controller, Controller commands, Block diagram of device controller, Types of Device controller.
Peripheral Interfaces : Parallel interface, Serial interface.
2. Peripheral Devices: Keyboard functions, Types of keyswitches, Keyboard layouts, Keyboard connectors, Keyboard Interface (8088-PC), Keyboard Interface-286, Keyboard lock, Keyboard organization, Roll over, Key bounce, Make and Break codes, Typematic Action, Keyboard Microcomputer.
Magnetic storage devices : Basic Principle : FM and MFM recording format, Disk drive types, Floppy Diskette, Hard sector and Soft sector Format, Floppy disk format.
Data Recording, Floppy disk drive : Head movement, Head coils, Spindle motors, PCB’s.
Hard Disk Drive : Types of Hard Disk Drives, Hard Drive Components, Hard Drive Specifications, Size and capacity, Hard Disk Drive organization, Data organization on Hard disk, Cylinder skewing, Zone bit Recording, Areal Density.
Printer : Printer Functions, Printer characteristics, Printer Types, Working of Laser Printer, Inkjet Printer, Dot Matrix Printer.
CRT Display Monitor: CRT Monitor Block Diagram.
Compact Discs, CD-ROM Drives, DVDs.
3. Printer Controller : Centronics Interface, Programming Sequence, Printer controller Functional Diagram, I/O ports – configuration, Printer Basics-DMP, EPP mode, ECP mode.
Display Adapters : CRT Display, CRT controller principle, CRT controller – Motorola 6845, Colour/Graphics Adapter, Keyboard controller.
4. Floppy Disk Controller : Floppy Disk Controller Overview, Disk Format, FDC System Interface, FDD Interface, Overall operations of Floppy Disk Subsystem, FDC IC, FDC commands, Sector Interleaving, Write precompensation, Data separation, Overview of Device Drive Design.
Hard Disk Controller : Overview of HDC Organization (ST-506), HDC Specifications and Features (ST-506), Disk Drive Types and Interface (ST-506), Controller Ports Description (ST-506), Features of ESDI, IDE, EIDE, SCSI.
5. Introduction to devices like scanner, Mouse, Trackball, Lightpen, Joystick, Barcode reader, RFID.
Internet Appliances : Introduction to Internet Appliances, Applications of Internet Appliances, X10 protocol.
Text Books:
1. Govindrajalu, IBM PC and Clones, Tata McGraw Hill.
2. Craig Zacker, John Rourke, PC Hardware : The Complete Reference , Tata
McGraw Hill.
Reference Books:
1. M. Ratiquzraman, Microprocessor and Microcomputer based design, UBS
2. Winn L. Rosch, Hardware Bible, 3rd Ed.

2:45 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home