4.4 Client side

The last piece is the client program actually triggering the actions at the server. We see it as an example on how to use our hello world server, and consequently place it into the $(PKGDIR)/examples/ directory tree. Create a new subdirectory there:

~/src/l4/pkg/hiworld/examples> mkdir client

Switch into it and create the source file main.c for sending requests to our server:

hiworld/examples/client/main.c
#include <stdio.h>
#include <l4/hiworld/hiworld.h>

char LOG_tag[9]="hiclient";

int main(void){
  int count;

  hiworld_print();
  count = hiworld_count();
  if(count>=0){
      printf("Hello world server returned %d.\n", count);
  } else {
      printf("Some problem with the hello world server occurred\n");
  }
  return 0;
}

Create a makefile that compiles a binary, and tell BID to link the client library created in Section 4.4.

hiworld/examples/client/Makefile
PKGDIR          ?= ../..
L4DIR           ?= $(PKGDIR)/../..

TARGET          = hiclient
SRC_C           = main.c
LIBS            = -lhiworld
DEFAULT_RELOC   = 0x01100000

include $(L4DIR)/mk/prog.mk

Compile the program:

~/src/l4/pkg/hiworld/examples/client> make O=/path/to/build



L4 Checker 2012-04-11