⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.c

📁 MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis的0.9.5版本的源码。
💻 C
字号:
//  This file is part of MANTIS OS, Operating System//  See http://mantis.cs.colorado.edu/////  Copyright (C) 2003,2004,2005 University of Colorado, Boulder////  This program is free software; you can redistribute it and/or//  modify it under the terms of the mos license (see file LICENSE)/**************************************************************************//* File:    client.c                                                      *//* Author   Jeff Rose   :    rosejn@colorado.edu                          *//*   Date: 06/09/04                                                       *//*                                                                        *//* A test app for the client side library of the gevent system.           *//**************************************************************************/#include "gevent.h"#define TEST_PORT  8888#define TEST_ADDR  "localhost"#define TEST_EVENT_ID 234gboolean send_func(gpointer data){   gevent_client *client = (gevent_client *)data;   gint event_id = TEST_EVENT_ID;   gchar buf[256] = "This is a test event.";      g_print("Sending event: %d\n", event_id);      if(gevent_client_send(client, event_id, buf, 20) == -1)   {      g_print("Server has disconnected... Exiting program!\n");      exit(-1);   }      return true;}int main(int argc, char** argv){   gchar* hostname;   gint port;   gint interval = 2000;   GMainLoop* main_loop;   gevent_client *client;   hostname = TEST_ADDR;   port = TEST_PORT;      /* Create the main loop */   main_loop = g_main_new(FALSE);     /* Create connection object */   client = gevent_client_new(hostname, port, NULL);   /* add the random function to be called periodically */   g_timeout_add (interval, send_func, client);      /* Start the main loop */   g_main_run (main_loop);   return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -