示例#1
0
void MainWindow::joinGame()
{
    res = 5;
    u = 0; lenu = 0; i = 0; leni = 0; pu = pi = 0;
    locUser.clear(); oppUser.clear();
    isStart = 0;
    lastPos = qMakePair(0, 0);

    QString ret = MyInputDialog::getIp();
    qDebug() << ret;
    char buf[20];
    memset(buf, 0, sizeof(buf));
    for (int i = 0; i < ret.size(); i++)
        buf[i] = ret[i].unicode();
    if (server.closeServer() &&
            client.closeClient() &&
            client.connectServer(buf, 4321)) {
        statusBar()->showMessage("Server connected.");
        createAction->setEnabled(0);
        joinAction->setEnabled(0);
        abortAction->setEnabled(1);
        player = 'B';
        locUser.load();
        clientSend(locUser.name.toLatin1(), 'U');
        clientSend(locUser.image, 'I');
        locName->setText(locUser.name);
        loc->paintImage(locUser.image);
        startButton->setEnabled(1);
    } else
        statusBar()->showMessage("Fail: connect.");
}
int main(int argc, char *argv[])
{
  char *host, *filename;
  int port;
  int clientfd;

  if (argc != 4) {
    fprintf(stderr, "Usage: %s <host> <port> <filename>\n", argv[0]);
    exit(1);
  }

  host = argv[1];
  port = atoi(argv[2]);
  filename = argv[3];

  /* Open a single connection to the specified host and port */
  int i;
  for(i=0;i<5;i++){
  clientfd = Open_clientfd(host, port);
  
  clientSend(clientfd, filename);
  clientPrint(clientfd);
    
  Close(clientfd);
  }

  exit(0);
}
int main(int argc, char *argv[])
{
  char *host, *filename;
  int port;
  int clientfd;
  int runs;
  if (argc != 5) {
    fprintf(stderr, "Usage: %s <host> <port> <filename> <runs>\n", argv[0]);
    exit(1);
  }

  host = argv[1];
  port = atoi(argv[2]);
  filename = argv[3];
  //runs = atoi(argv[4]);
  /* Open a single connection to the specified host and port */
  printf("host: %s port: %d filename: %s runs: %d\n", host, port, filename, runs);
  clientfd = Open_clientfd(host, port);
  clientSend(clientfd, filename);
  clientPrint(clientfd);
    
  Close(clientfd);

  exit(0);
}
示例#4
0
void* workers(void* _filename){
  char* filename = (char*) _filename;
  //printf("file:%s\n", filename);
  int clientfd = Open_clientfd("localhost", 8559);
  clientSend(clientfd, filename);
  clientPrint(clientfd);
  Close(clientfd);  
  return NULL;
}
示例#5
0
char *fetch(char *link) {
  char url[256];
  snprintf(url, 256, "/~harter/537/p4/%s", link);
  int clientfd = Open_clientfd("pages.cs.wisc.edu", 80);
  ///~harter/537/  clientSend(clientfd, "/~harter/537/slides.html");
  clientSend(clientfd, url);
  char *page = grab_page(clientfd);
  Close(clientfd);
  return page;
}
示例#6
0
int main(void)
{
	
    WatchDogDisable();

    NutDelay(100);

    SysInitIO();
	
	SPIinit();
    
	LedInit();
	
	LcdLowLevelInit();
	LcdBackLight(1);
	PrintStr("Starting System");
    Uart0DriverInit();
    Uart0DriverStart();
	LogInit();

    CardInit();

	char custom[48] = ALL;
	
	LoadCustomChars(custom, 6);
	
    X12Init();
    if (X12RtcGetClock(&gmt) == 0)
    {
		LogMsg_P(LOG_INFO, PSTR("RTC time [%02d:%02d:%02d]"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
    }

    if (At45dbInit()==AT45DB041B)
    {
        // ......
    }


    RcInit();
    
	KbInit();

    SysControlMainBeat(ON);             // enable 4.4 msecs hartbeat interrupt
	
	ClearLcdScreen();

	//Nieuwe threads aanmaken
    NutThreadCreate("t01", Thread1, NULL, 512);
	NutThreadCreate("time", TimeUpdater, NULL, 512);
	
	//Start netwerk
	int i = initNetworkDHCP();
	LogMsg_P(LOG_INFO, PSTR("Ethernet Startup Message: [%d]"),i);

	//Haal Internet tijd op
	pgmt = getNTPTime();
	X12RtcSetClock(&pgmt);
	//LogMsg_P(LOG_INFO, PSTR("New RTC time [%02d:%02d:%02d]"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec );

    /*
     * Increase our priority so we can feed the watchdog.
     */
    NutThreadSetPriority(1);

	/* Enable global interrupts */
	sei();

	/******************NETWERK**TEST*****************************************************/

	//Maak nieuwe socket
	TCPSOCKET *sock;
	sock = NutTcpCreateSocket();
	//Connect met google.nl
	LogMsg_P(LOG_INFO, PSTR("Connecting client"));
	clientConnect(sock);
	//Zend http req
	clientSend(sock,buffer,sizeof(buffer));

	//Ontvang response in buffer --> grotere buffer (1500)= crash-->heapsize??(8k ram)
	char rcvbuffer [500];
	int rec;
	rec = clientReceive(sock,rcvbuffer,sizeof(rcvbuffer));
	LogMsg_P(LOG_INFO, PSTR("received [%d]"),rec);

	//0 terminate buffer(string)
	//rcvbuffer[499] = 0;

	//Print buffer(http response enz)
	LogMsg_P(LOG_INFO, PSTR("received [%s]"),rcvbuffer);
	
	//Sluit connectie
	clientClose(sock);
	/***********************************************************************************/

	//Main gui besturing??
    for (;;)
    {
        NutSleep(100);
        WatchDogRestart();
    }

    return(0);      
}
示例#7
0
文件: locktests.c 项目: 1587/ltp
int sendResult(int resultat)
{
	serialiseResult(resultat);
	clientSend();
	return 0;
}