这篇教程C++ sock_write函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中sock_write函数的典型用法代码示例。如果您正苦于以下问题:C++ sock_write函数的具体用法?C++ sock_write怎么用?C++ sock_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了sock_write函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fserve_client_createint fserve_client_create(client_t *httpclient, char *path){ fserve_t *client = calloc(1, sizeof(fserve_t)); int bytes; int client_limit; ice_config_t *config = config_get_config(); client_limit = config->client_limit; config_release_config(); client->file = fopen(path, "rb"); if(!client->file) { client_send_404(httpclient, "File not readable"); return -1; } client->client = httpclient; client->offset = 0; client->datasize = 0; client->ready = 0; client->buf = malloc(BUFSIZE); global_lock(); if(global.clients >= client_limit) { httpclient->respcode = 504; bytes = sock_write(httpclient->con->sock, "HTTP/1.0 504 Server Full/r/n" "Content-Type: text/html/r/n/r/n" "<b>Server is full, try again later.</b>/r/n"); if(bytes > 0) httpclient->con->sent_bytes = bytes; fserve_client_destroy(client); global_unlock(); return -1; } global.clients++; global_unlock(); httpclient->respcode = 200; bytes = sock_write(httpclient->con->sock, "HTTP/1.0 200 OK/r/n" "Content-Type: %s/r/n/r/n", fserve_content_type(path)); if(bytes > 0) httpclient->con->sent_bytes = bytes; sock_set_blocking(client->client->con->sock, SOCK_NONBLOCK); sock_set_nodelay(client->client->con->sock); thread_mutex_lock (&pending_lock); client->next = (fserve_t *)pending_list; pending_list = client; thread_mutex_unlock (&pending_lock); return 0;}
开发者ID:miksago,项目名称:icecast,代码行数:54,
示例2: proto_senduint32_t proto_send(uint16_t header, sock_t* s){ prefix_t prefix; prefix.header = (header | MAGIC); prefix.length = 0; sock_write(s, &prefix, sizeof(prefix.header)); sock_write(s, &prefix.length, sizeof(prefix.length)); return sock_flush(s);}
开发者ID:abingham,项目名称:ponyc,代码行数:12,
示例3: ServerSendReplyint GUIAPI ServerSendReply (int clifd, const void* reply, int len){ MSG reply_msg = {HWND_INVALID, 0}; if (!mgIsServer) return SOCKERR_IO; /* send a reply message to indicate this is a reply of request */ if (sock_write (clifd, &reply_msg, sizeof (MSG)) < 0) return SOCKERR_IO; if (sock_write (clifd, reply, len) < 0) return SOCKERR_IO; return SOCKERR_OK;}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:14,
示例4: mainvoid main(){ int bytes_read; char buffer[100]; /* Currently (DC 7.30), printf() has max 127 bytes it can output. */ tcp_Socket socket; sock_init(); while(1) { tcp_listen(&socket,PORT,0,0,NULL,0); printf("Waiting for connection.../n"); while(!sock_established(&socket) && sock_bytesready(&socket)==-1) tcp_tick(NULL); printf("Connection received.../n"); do { bytes_read=sock_fastread(&socket,buffer,sizeof(buffer)-1); if(bytes_read>0) { buffer[bytes_read]=0; printf("%s",buffer); sock_write(&socket,buffer,bytes_read); } } while(tcp_tick(&socket)); printf("Connection closed.../n"); }}
开发者ID:jgambox,项目名称:DCRabbit_9,代码行数:30,
示例5: socket_writeint socket_write(Socket_T S, void *b, int size) { int n= 0; void *p= b; ASSERT(S); /* Clear any extra data read from the server */ socket_reset(S); while(size > 0) { if(S->ssl) { n= send_ssl_socket(S->ssl, p, size, S->timeout); } else { if(S->type==SOCK_DGRAM) n= udp_write(S->socket, p, size, S->timeout); else n= sock_write(S->socket, p, size, S->timeout); } if(n <= 0) break; p+= n; size-= n; } if(n < 0) { /* No write or a partial write is an error */ return -1; } return (int)(p - b); }
开发者ID:andreax79,项目名称:monit,代码行数:35,
示例6: exec_lua_cbstatic void exec_lua_cb( Widget w, void *u, void *c ){ TRACE(1,"arg: %s", (char*) u); int sln = CWNET.sln; int fd = sln_get_fd(sln ); if( fd < 0 ) { WARN("no connections to lua server"); return; } char *filename = (char*) u; FILE *fp = fopen( filename, "r" ); if(!fp) WARN("faild to open %s", filename ); else { int buf = m_create(1000,1); int ch; int crc=0; /* write program header to slop buffer */ crc = slop_encode_str(buf,crc, "PUT:"); /* write program to slop buffer, -1 will finalize the packet */ do { ch=fgetc(fp); crc = slop_encode(buf,crc, ch); } while( ch >= 0); fclose(fp); sock_write(fd,buf); } }
开发者ID:xtforever,项目名称:xtcw,代码行数:34,
示例7: send_optionvoidsend_option(int type, int opt){ int ret; int size; unsigned char *obp; obp = &Comobuf[0]; *obp++ = IAC; *obp++ = type; *obp++ = opt; size = 3; obp = &Comobuf[0]; if (Debug > 2) { sysmessage(MSG_DEBUG, "Sock_write, 3 bytes: %02X %02X %02X/n", Comobuf[0], Comobuf[1], Comobuf[2]); } while (size) { if ((ret = sock_write(obp, size)) == -1) { SET_EVENT(EV_RN, EV_RNHANG, 0, 0); break; } else if (ret != size) { sysmessage(MSG_NOTICE, "Partial write in send_option: %d/%d/n", ret, size); sysdelay(ROOM_DELAY); /* Wait for room */ } size -= ret; obp += ret; }}
开发者ID:maquefel,项目名称:cyclades-serial-code,代码行数:35,
示例8: command_buildm3ustatic void command_buildm3u(client_t *client, source_t *source, int response){ char *username = NULL; char *password = NULL; char *host = NULL; int port = 0; ice_config_t *config; COMMAND_REQUIRE(client, "username", username); COMMAND_REQUIRE(client, "password", password); config = config_get_config(); host = strdup(config->hostname); port = config->port; config_release_config(); client->respcode = 200; sock_write(client->con->sock, "HTTP/1.0 200 OK/r/n" "Content-Type: audio/x-mpegurl/r/n" "Content-Disposition = attachment; filename=listen.m3u/r/n/r/n" "http://%s:%[email C++ sock_xmit函数代码示例 C++ sock_unregister函数代码示例
|