AMC 68VZ328 software manual Simple Server & Client, Inetd based Server & Client

Page 86

Simple Server & Client

The sample programs server.c and client.c are available in the SDK samples directory,

/opt/user_code/networking/filetransfer/without_inetd. The programs interact using Internet sockets, AF_INET. Once the sockets have been established they can be read from and written to in order to transfer information. Each program will be run on a separate NETdimm, and using the IP addresses established during configuration, text files such as hello.txt can be transferred between them.

The server will set up its own socket and wait for an incoming client socket. Upon accepting a client connec- tion, it will set up a client socket, and go through a series of read and write operations on the socket to accept the file transfer.

On the client side, it will set up a socket and then attempt to connect to a server. Once a connection has been established the socket will be used for reads and writes to the server to transfer the file.

Note that the port that the client and server sockets will connect through must be the same. It has been hard coded in the program during the socket setups.

Inetd based Server & Client

The sample programs inetServer.c and inetClient.c are available in the SDK samples directory,

/opt/user_code/networking/filetransfer/with_inetd. These programs interact through the internet daemon, inetd. Similar to the simple server and client programs, a text file can be transferred between two NETdimms using the IP addresses established during configuration.

The following instructions must be added to the config files of the root file system of both NETdimm modules for the inet based server and client to work. In /etc/services the service that needs to be called, inetServer, must be added to the list in the format

service-name

port/protocol

eg.

inetServer

9735/tcp

The port number can be chosen arbitrarily, so long as it does not already exist in the services list and is not below 1024, which are reserved for system use.

In /etc/inetd.conf the program and path that inetd will load must be added in the format

service-name endpoint-type protocol wait-status uid server-program server- arguments

eg. inetServer stream tcp nowait root /usr/inetServer

The server side of the program is started by inetd, allowing the read and write operations to go to standard input and output. inetd will listen on all service ports for the services listed in

86

www.amctechcorp.com

Image 86
Contents DimmPCITM 68VZ328 Hardware / Software Manual DimmPCITM Software Development Kit Copyright noticeContact Information NETdimm Developers Kit Quick Start Guide Etc/issue Page This page left intentionally blank Introduction Launching Linux at the embeddedPage What’s on the CD? System RequirementsThis page left intentionally blank CPU Module FeaturesUC68VZ328 Embedded Microcontroller BackplaneGeneral Description CPU Module DescriptionBackplane Description Architecture CPU ArchitectureMemory Map MCU CoreSystem Memory Memory Memory MapLayout of the Flash and Flash Schematic Layout of the Flash Sdram Ethernet Controller Viewing the Ethernet MAC IDNETdimm Ethernet Schematic Digital I/O IOdimmDigital Output Schematic Analog Output Schematic Analog Input Schematic Digital to Analog Converter Schematic Highlights RS-232Watchdog Usage LCD Schematic LCD InterfaceDimmPCITM Signal Descriptions DimmPCITM signals for System SlotPCI Electrical Characteristics Maximum RatingsThis page left intentionally blank Builder Kit Installing the dimmPCI TM SystemInstallation Before beginningConfiguring and compiling the µClinux kernel Creating a ROM image Customizing the filesystemAccessing your dimmPCI development board via the serial port Dynamic IP Accessing the NetworkStatic IP Accessing your dimmPCI development board via telnet Compiling your own source codeUsing NFS to streamline the development cycle Home directory/dimmpci/source Updating Applications on your dimmPCI module MethodThis page left intentionally blank Programming the uC68VZ328 LoaderOops Cd /opt/boottools/oops Oops -p /dev/ttyS0 -k kernel.bin Page Page This page left intentionally blank Appendix Sample CodeClose the file afterwards fclose filehandle Page Longwatchdogid #include unistd.h #include stdio.h int main void This page left intentionally blank Journalling Flash File System Umount /usr Sbin/mkjffs /dev/flash0 Page This page left intentionally blank Development Tool Chains Normal Usage of the PIC-COFFTool Chain Page This page left intentionally blank D1 Application Note IntroductionKernel and Filesystem Configuration Kernel and Filesystem Configuration Flow Chart YESAvailable Digital I/O Pins List of all available digital I/O pins Programming Structure Dimmio structure descriptionDigital I/O Functions Page Sample Programs In0 In1 In2 In3 In4 In5 In6 In7 Out0 Even ParityMknod io1 c 123 Page This page left intentionally blank D2 Application Note AbstractKernel Configuration RequirementsAgain, from the main menu under Network device support Kernel Configuration Flow Chart AtCommandPrompt Filesystem Configuration Cd /opt/filesystem name make clean Make Filesystem Configuration Flow Chart Modifications to ‘rc’ fileHost machine Configuration TestingPage This page left intentionally blank Using Multiple NETdimm Modules Application NoteSimple Server & Client Inetd based Server & ClientPage This page left intentionally blank Using Analog and Digital I/O with IOdimmCd /opt Cp -Rpdx newfs iodimmmfs ADC MAX1203 Available I/O Pins Category Channel Backplane System Backplane Header Slot PinFunctions Digital Inputs and Outputs+ Κ Iodimm/dio Samples/cardspecific/iodimm/dio Page This page left intentionally blank Using Oops Purpose & basic format of files for oopsUpload & Flash Upload & Run DownloadCommon oops program arguments Appendix This page left intentionally blank 104 Preamble Licensing, Copyrights & LiabilityDimmPCITM Software Development Kit Distribution 106 107 108 109 No Warranty Appendix How to Apply These Terms to Your New Programs111 112 113 This page left intentionally blank 114 References/ Suggested Reading