本文整理汇总了C++中send_to_server函数的典型用法代码示例。如果您正苦于以下问题:C++ send_to_server函数的具体用法?C++ send_to_server怎么用?C++ send_to_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_to_server函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serverConnect
void serverConnect(){
connect_to_server("130.195.6.196", 1024);
send_to_server("Please");
char message[24];
receive_from_server(message);
send_to_server(message);
}
示例2: main
int main(int argc, char *argv[]) {
int sockfd, portno;
char buffer[MAXPAGESIZE];
if (argc < 3) {
fprintf(stderr,"usage %s hostname port [kill]\n", argv[0]);
exit(0);
}
portno = atoi(argv[2]);
sockfd = setup_socket(argv[1], portno);
bzero(buffer,MAXPAGESIZE);
if (argc > 3 && !strcmp(argv[3], "kill")) {
send_to_server(sockfd, "please terminate");
close(sockfd);
return 0;
}
send_to_server(sockfd, "initiate session");
// while we get input transfer to server
while (gets(buffer+1)) {
// we do type request
buffer[0] = 't';
strcat(buffer, "\n");
send_to_server(sockfd, buffer);
}
// close socket
close(sockfd);
return 0;
}
示例3: move
void move(Player* player, Move direction, block** map, client_network out){
switch(direction){
/*case BOT:
if(canGoToBlock(player->position[0], player->position[1], 0, 1, map)){
player->position[1]++;
}
else{
#ifdef DEBUG
printf("Bot direction not possible\n");
#endif
}
break;*/
case RIGHT:
if(canGoToBlock(player->position[0], player->position[1], 1, 0, map)){
player->position[0]++;
char* request = Requete_Deplacement_Envoi(direction);
send_to_server(out, request, strlen(request));
}
else{
#ifdef DEBUG
printf("Right direction not possible\n");
#endif
}
break;
case LEFT:
if(canGoToBlock(player->position[0], player->position[1], -1, 0, map)){
player->position[0]--;
char* request = Requete_Deplacement_Envoi(direction);
send_to_server(out, request, strlen(request));
}
else{
#ifdef DEBUG
printf("Left direction not possible\n");
#endif
char* request = Requete_Deplacement_Envoi(direction);
send_to_server(out, request, strlen(request));
}
break;
case TOP:
if(!player->falling && (canGoToBlock(player->position[0], player->position[1], 0, -1, map))){
player->position[1]--;
char* request = Requete_Deplacement_Envoi(direction);
send_to_server(out, request, strlen(request));
}
else{
#ifdef DEBUG
printf("Top direction not possible\n");
#endif
}
break;
default:
#ifdef DEBUG
printf("Direction not know\n");
#endif
break;
}
}
示例4: openDoor
int openDoor(){
if(connect_to_server("130.195.6.196", 1024) == 0){
send_to_server("Please");
char message[24];
receive_from_server(message);
send_to_server(message);
return 0;
}else{return 1;}
}
示例5: main
int main(){
init(1);
int x;
connect_to_server("130.195.6.196", 1024); //Opening the gate code
send_to_server("Please");
char message[24];
receive_from_server(message);
printf("%s", message);
send_to_server(message);
for (x = 0; x < 8; x++)
{
select_IO(x,0);
write_digital(x,1);
}
while(1){
take_picture();
int sum = 0;
float kp = 0.5;
int w;
int s;
int proportional_signal=0;
for(int x = 0; x < 320; x++){
w = get_pixel(x,120,3);
if(w>127){s=1;}
else{s=0;};
sum = sum + (x-160)*s;}
proportional_signal = sum * kp;
if (sum < 0){
set_motor(1, proportional_signal);
set_motor(2, -1*proportional_signal);
}
else if (sum > 0){
set_motor(1, -1*proportional_signal);
set_motor(2, proportional_signal);
}
else{
set_motor(1, proportional_signal);
set_motor(2, proportional_signal);
}
update_screen();
for (x = 0 ; x < 8; x++)
{
int adc_reading = read_analog(x);
printf("ai=%d av=%d\n",x,adc_reading);
}
}
set_motor(1,0);
set_motor(2,0);
return 0;
}
示例6: openGate
// https://github.com/kaiwhata/ENGR101-2016/wiki/Network-commands
// more detail on open gate
void openGate(){
connect_to_server((char *)"130.195.6.196", 1024);
send_to_server((char *)"Please");
char message[24];
receive_from_server(message);
// null character limits message length at 6 characters long
message[MESSAGE_LENGTH] = '\0';
send_to_server(message);
printf("%s", message);
}
示例7: open_gate
/**
* Sends a request to the gate server to open the gate.
*/
void open_gate()
{
// Establishes a connection to the gate's server
connect_to_server(ip, port);
// Sends the request to open the gate
send_to_server(request);
// Receives the password from the server
receive_from_server(password);
// Sends the password for the gate
send_to_server(password);
}
示例8: setup_ov_mode
void setup_ov_mode(int on, int hide, int log)
{
#ifdef WANT_OPERVIEW
char *default_oper = "wsckf";
Window *win = NULL;
if (on)
{
if ((win = get_window_by_name("oper_view")))
{
if (win->log)
do_log(0, NULL, &win->log_fp);
delete_window(win);
update_all_windows();
set_input_prompt(current_window, get_string_var(INPUT_PROMPT_VAR), 0);
cursor_to_input();
}
send_to_server("MODE %s -%s%s", get_server_nickname(from_server), get_string_var(OPER_MODES_VAR)?get_string_var(OPER_MODES_VAR):default_oper, send_umode);
}
else
{
Window *tmp = NULL;
win = current_window;
if ((tmp = new_window(current_window->screen)))
{
malloc_strcpy(&tmp->name, "oper_view");
tmp->double_status = 0;
if (hide)
hide_window(tmp);
else
resize_window(1, tmp, -5);
tmp->window_level = LOG_WALLOP|LOG_OPNOTE|LOG_SNOTE;
tmp->absolute_size = 1;
tmp->skip = 1;
set_wset_string_var(tmp->wset, STATUS_FORMAT1_WSET, fget_string_var(FORMAT_OV_FSET));
build_status(tmp, NULL, 0);
update_all_windows();
set_input_prompt(current_window, get_string_var(INPUT_PROMPT_VAR), 0);
cursor_to_input();
send_to_server("MODE %s +%s", get_server_nickname(from_server), get_string_var(OPER_MODES_VAR)?get_string_var(OPER_MODES_VAR):default_oper);
set_screens_current_window(win->screen, win);
tmp->mangler = operlog_line_mangler;
if (log != -1)
{
tmp->log = log;
if (tmp->log)
do_log(log, "~/.BitchX/operview.log", &tmp->log_fp);
}
}
}
#endif
}
示例9: test_upt
void test_upt() {
OekMsg msgs[2];
msgs[0] = _get_stacmd();
msgs[1] = NULL;
send_to_server(msgs);
assert(!read_from_server("\"start\""));
msgs[2];
msgs[0] = _get_uptcmd();
send_to_server(msgs);
assert(read_from_server("err") == 0);
}
示例10: init_server
int init_server(t_cnt *cnt)
{
char buf[200];
debug("init_server()");
snprintf(buf, sizeof(buf), MESG_PASS, EMPTY);
send_to_server(cnt, buf);
snprintf(buf, sizeof(buf), MESG_NICK, (char *) cnt->nick);
send_to_server(cnt, buf);
snprintf(buf, sizeof(buf), MESG_USER, (char *) cnt->real, MODE, MODE, MODE);
send_to_server(cnt, buf);
snprintf(buf, sizeof(buf), MESG_JOIN, (char *) cnt->chan);
send_to_server(cnt, buf);
return (0);
}
示例11: main
int main (){
// This sets up the RPi hardware and ensures
// everything is working correctly
init(1);
//connects to server with the ip address 192.168.1.2
connect_to_server("130.195.6.196", 1024);
//sends a message to the connected server
send_to_server("Please");
//receives message from the connected server
char message[24];
receive_from_server(message);
send_to_server(message);
printf("%s", message);
return 0;}
示例12: prompt
void prompt() {
char cmdBuf[MAX_COMMAND_LEN];
memset(cmdBuf, 0, MAX_COMMAND_LEN);
printf("mdb-cli > ");
fflush(stdout);
int cmdLen = read(STDIN_FILENO, cmdBuf, MAX_COMMAND_LEN);
if (cmdLen < 0) {
/* do nothing */
}
//dieWithMessage("read: failed");
else if (cmdLen == 1) {
/* empty command. do nothing */
} else {
// 发送query请求
send_to_server(listen_sock, cmdBuf);
// 读取server返回的结果
int result = read_reply(listen_sock);
//客户端请求退出,服务端确认了
//RESP_CODE_DISCONNECT 代表客户端退出
if (result == RESP_CODE_DISCONNECT)
gQuit = 1;
}
}
示例13: if
void chat_handler::send_command(const std::string& cmd, const std::string& args /* = "" */) {
config data;
if (cmd == "muteall") {
data.add_child(cmd);
}
else if (cmd == "query") {
data.add_child(cmd)["type"] = args;
}
else if (cmd == "ban" || cmd == "unban" || cmd == "kick"
|| cmd == "mute" || cmd == "unmute") {
data.add_child(cmd)["username"] = args;
}
else if (cmd == "ping") {
data[cmd] = std::to_string(time(nullptr));
}
else if (cmd == "green") {
data.add_child("query")["type"] = "lobbymsg @" + args;
}
else if (cmd == "red") {
data.add_child("query")["type"] = "lobbymsg #" + args;
}
else if (cmd == "yellow") {
data.add_child("query")["type"] = "lobbymsg <255,255,0>" + args;
}
else if (cmd == "report") {
data.add_child("query")["type"] = "report " + args;
}
else if (cmd == "join") {
data.add_child("room_join")["room"] = args;
}
else if (cmd == "part") {
data.add_child("room_part")["room"] = args;
}
send_to_server(data);
}
示例14: send_to_server
void vsx_widget_controller_pad::event_mouse_move(vsx_widget_distance distance,vsx_widget_coords coords)
{
if (drawing) {
float xx = ((distance.center.x+draw_area)/(draw_area*2));
if (xx < 0.0f) xx = 0.0f;
if (xx > 1.0f) xx = 1.0f;
tracer.x = ((vsx_widget_controller_knob*)knob_x1)->value + xx * (((vsx_widget_controller_knob*)knob_x2)->value - ((vsx_widget_controller_knob*)knob_x1)->value);
float yy = (1-(distance.center.y+draw_area)/(draw_area*2));
if (yy < 0.0f) yy = 0.0f;
if (yy > 1.0f) yy = 1.0f;
tracer.y = ((vsx_widget_controller_knob*)knob_y1)->value + yy * (((vsx_widget_controller_knob*)knob_y2)->value - ((vsx_widget_controller_knob*)knob_y1)->value);
prev_draw[prev_pos].x = distance.center.x;
prev_draw[prev_pos].y = distance.center.y;
if (prev_draw[prev_pos].x < -draw_area) prev_draw[prev_pos].x = -draw_area;
if (prev_draw[prev_pos].y < -draw_area) prev_draw[prev_pos].y = -draw_area;
if (prev_draw[prev_pos].x > draw_area) prev_draw[prev_pos].x = draw_area;
if (prev_draw[prev_pos].y > draw_area) prev_draw[prev_pos].y = draw_area;
prev_draw[prev_pos].z = 2.0f;
prev_pos++;
if (prev_pos > 300) prev_pos = 0; // cyclic buffer
for (unsigned long i = 0; i < prev_draw.size(); i++)
{
prev_draw[i].z -= 2.0f/300.0f;
if (prev_draw[i].z < 0.0f) prev_draw[i].z = 0.0f;
}
send_to_server();
}
else vsx_widget_controller_base::event_mouse_move(distance,coords);
}
示例15: join_last_invite
void join_last_invite(char dumb, char *dumber)
{
if (invite_channel)
send_to_server(SERVER(from_server), "JOIN %s", invite_channel);
else
bitchsay("You haven't been invited to a channel yet");
}