本文整理汇总了C++中send_request函数的典型用法代码示例。如果您正苦于以下问题:C++ send_request函数的具体用法?C++ send_request怎么用?C++ send_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_request函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: network_status
void network_status(){
dhcp_pair *pair = NULL;
pair = (dhcp_pair *) malloc(sizeof(dhcp_pair));
memset(pair, 0, sizeof(dhcp_pair));
// Read from /tmp/wista.txt or from command to get mac link to server
read_wlan_client(pair);
// Form json to get ip
char *json = form_request_json(pair);
// Send Request
char response[4096];
int resp_len;
memset(response, 0, sizeof(response));
//send_request("192.168.48.1", PORT, "/dhcplease", json, strlen(json), response, resp_len);
send_request("127.0.0.1", PORT, "/dhcplease", json, strlen(json), response, resp_len);
//printf("response[%d]=[%s]\n", resp_len, response);
char *p = strstr(response, "\r\n\r\n");
if (p) {
parse_response_json(p+strlen("\r\n\r\n"), pair);
}
result_array ret[64];
memset(&ret, 0, sizeof(ret));
int i=0;
for(i=0; i<pair->length; i++) {
//printf("mac[%d]=%s\n", i, pair->value[i].mac);
//printf(" ip[%d]=%s\n", i, pair->value[i].ip);
ret[i] = network_delay(pair->value[i].ip);
int j=0;
for (j=0; j< PKT_LEN; j++)
printf("ip[%s]-max[%f]-min[%f]-avg[%f]\n", pair->value[i].ip,
ret[i].icmp[j].max, ret[i].icmp[j].min, ret[i].icmp[j].avg);
}
//TODO: No json defined
//Form json post to magicwifi
//Send request to magicwifi
}
开发者ID:qianguozheng,项目名称:datastructure,代码行数:43,代码来源:client.c
示例2: interpret
/*
* Interpret - Read and pass GET request for client
*/
int interpret(int client) {
struct HTTP_Request req;
char buf[BUFSIZE];
char current[BUFSIZE];
char resp[BUFSIZE];
int read_len = 0;
int len = 0;
int rv;
fd_set set;
FD_ZERO(&set);
FD_SET(client, &set);
struct timeval timeout;
timeout.tv_sec = 10;
while ((rv = select(client + 1, &set, NULL, NULL, &timeout)) > 0) {
/* Read input from user */
read_len = recv(client, &buf[len], (BUFSIZE-len), 0);
/* Finish request if buf is empty */
if (strlen(buf) == 0) {
printf("BUF IS EMPTY\n");
break;
}
/* Overwrite trailing new line */
buf[read_len-1] = '\0';
strcpy(req.site, "192.168.2.1");
printf("'%s'\n", buf);
strcpy(req.full_req, buf);
req.port = 22;
if (send_request(client, req) < 0) {
errexit("echo write: %s\n", strerror(errno));
}
}
printf("Exiting\n");
return 0;
}
开发者ID:FalconerTC,项目名称:CSCI4273,代码行数:46,代码来源:webproxy.c
示例3: request_fetchfields
/*
* Fetch the specified header fields, ie. BODY[HEADER.FIELDS (<fields>)], of
* the messages.
*/
int
request_fetchfields(session *ssn, const char *mesg, const char *headerfields,
char **fields, size_t *len)
{
int t, r;
{
int n = strlen("BODY.PEEK[HEADER.FIELDS ()]") +
strlen(headerfields) + 1;
char f[n];
snprintf(f, n, "%s%s%s", "BODY.PEEK[HEADER.FIELDS (",
headerfields, ")]");
TRY(t = send_request(ssn, "UID FETCH %s %s", mesg, f));
}
TRY(r = response_fetchbody(ssn, t, fields, len));
return r;
}
开发者ID:Papafox,项目名称:imapfilter,代码行数:23,代码来源:request.c
示例4: music_button_toggled
static void music_button_toggled (GtkWidget *widget, gpointer data)
{
MMConversation *mmconv = mmconv_from_conv(((MMConversation *) data)->conv);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
{
if (((MMConversation *) data)->requested)
{
start_session(mmconv);
send_request_confirmed(mmconv);
}
else
{
((MMConversation *) data)->originator = TRUE;
send_request((MMConversation *) data);
}
} else {
session_end((MMConversation *)data);
}
}
开发者ID:Distrotech,项目名称:pidgin,代码行数:19,代码来源:musicmessaging.c
示例5: process_request
/* connects to a host on a specified port, sends a string, and gets a
response */
int
process_request (const char *server_address, int server_port, int proto,
const char *send_buffer, char *recv_buffer, int recv_size)
{
int result;
int sd;
result = STATE_OK;
result = np_net_connect (server_address, server_port, &sd, proto);
if (result != STATE_OK)
return STATE_CRITICAL;
result = send_request (sd, proto, send_buffer, recv_buffer, recv_size);
close (sd);
return result;
}
开发者ID:Bobzikwick,项目名称:monitoring-plugins,代码行数:21,代码来源:netutils.c
示例6: dlbindreq
static int
dlbindreq(int fd, bpf_u_int32 sap, char *ebuf)
{
dl_bind_req_t req;
memset((char *)&req, 0, sizeof(req));
req.dl_primitive = DL_BIND_REQ;
/* XXX - what if neither of these are defined? */
#if defined(DL_HP_RAWDLS)
req.dl_max_conind = 1; /* XXX magic number */
req.dl_service_mode = DL_HP_RAWDLS;
#elif defined(DL_CLDLS)
req.dl_service_mode = DL_CLDLS;
#endif
req.dl_sap = sap;
return (send_request(fd, (char *)&req, sizeof(req), "bind", ebuf));
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:19,代码来源:pcap-dlpi.c
示例7: safe_stoi
void ClientParser::read(std::vector<std::string> commands) {
if( commands.size() != 2 ) {
std::cout << "Error: Bad read params" << std::endl;
return;
}
// Get User
auto user = commands.front();
// Get Index
int index = safe_stoi( commands.at(1) );
if( index < 1 ) {
std::cout << "Error: Bad read params" << std::endl;
return;
}
// Send Request
auto client = Client::get_instance();
bool status = client->send_request( Request::get( user, index ) );
if( !status ) {
std::cout << "Error: Request could not send to the server!";
}
// Read Request
auto response = client->read_until('\n');
if( is_error(response) ) {
std::cout << response;
return;
}
std::cout << utils::split( response ).at(1) << std::endl;
int byte_count = std::stoi( utils::split( response ).back() );
std::cout << client->read_for( byte_count ) << std::endl;
}
开发者ID:film42,项目名称:cs360,代码行数:43,代码来源:client_parser.cpp
示例8: gs_snapd_list
JsonArray *
gs_snapd_list (const gchar *macaroon, gchar **discharges,
GCancellable *cancellable, GError **error)
{
guint status_code;
g_autofree gchar *reason_phrase = NULL;
g_autofree gchar *response_type = NULL;
g_autofree gchar *response = NULL;
g_autoptr(JsonParser) parser = NULL;
JsonObject *root;
JsonArray *result;
if (!send_request ("GET", "/v2/snaps", NULL,
macaroon, discharges,
&status_code, &reason_phrase,
&response_type, &response, NULL,
cancellable, error))
return NULL;
if (status_code != SOUP_STATUS_OK) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
"snapd returned status code %u: %s",
status_code, reason_phrase);
return NULL;
}
parser = parse_result (response, response_type, error);
if (parser == NULL)
return NULL;
root = json_node_get_object (json_parser_get_root (parser));
result = json_object_get_array_member (root, "result");
if (result == NULL) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
"snapd returned no result");
return NULL;
}
return json_array_ref (result);
}
开发者ID:endlessm,项目名称:gnome-software,代码行数:43,代码来源:gs-snapd.c
示例9: send_hostsstartendupdate
void send_hostsstartendupdate(connection_t *c, int start) {
char rawhost[MAX_STRING_SIZE];
char rawdgst[MAX_STRING_SIZE], b64dgst[MAX_STRING_SIZE];
size_t slen, dlen, rlen;
bool choice = false;
/* test if we're are authorized to broadcast the data */
if(!get_config_bool(lookup_config(config_tree, "HostsFilesMaster"), &choice)) return;
if(!choice) return;
/* bootstrapped node? If we're already sent him updates, do not do that again */
if(c->node && c->node->sentupdates) return;
/* Start update session */
dlen = RSA_size(myself->connection->rsa_key);
if (dlen > sizeof(rawdgst)/2) {
logger(LOG_ERR, "Could not %s hosts update session due to digest overflow",
start ? "start" : "end");
return;
}
snprintf(rawhost, sizeof(rawhost), "%s %s %s 0 %zd",
myself->name, myself->name, start ? "START" : "END", dlen);
rlen = strlen(rawhost);
if (!EVP_sign(myself->connection->rsa_key, rawhost, rlen, rawdgst, &dlen)) {
logger(LOG_ERR,
"Could not %s hosts update session due to signing error (probably OOM)",
start ? "start" : "end");
return;
}
if (base64_enclen(dlen) >= MAX_STRING_SIZE) {
logger(LOG_ERR,
"Could not %s hosts update session, base64 digest overflow",
start ? "start" : "end");
return;
}
base64_encode(rawdgst, dlen, b64dgst, sizeof(b64dgst)-1);
send_request(c, "%d %s %s", HOSTUPDATE, rawhost, b64dgst);
}
开发者ID:gvsurenderreddy,项目名称:tinc-1.0.16_hostupd,代码行数:42,代码来源:protocol_hostsupdate.c
示例10: check_interfaces
void
check_interfaces(void)
{
struct interface *ifp;
int rc, ifindex_changed = 0;
unsigned int ifindex;
FOR_ALL_INTERFACES(ifp) {
ifindex = if_nametoindex(ifp->name);
if(ifindex != ifp->ifindex) {
debugf("Noticed ifindex change for %s.\n", ifp->name);
ifp->ifindex = 0;
interface_up(ifp, 0);
ifp->ifindex = ifindex;
ifindex_changed = 1;
}
if(ifp->ifindex > 0)
rc = kernel_interface_operational(ifp->name, ifp->ifindex);
else
rc = 0;
if((rc > 0) != if_up(ifp)) {
debugf("Noticed status change for %s.\n", ifp->name);
interface_up(ifp, rc > 0);
}
if(if_up(ifp)) {
/* Bother, said Pooh. We should probably check for a change
in IPv4 addresses at this point. */
check_link_local_addresses(ifp);
check_interface_channel(ifp);
rc = check_interface_ipv4(ifp);
if(rc > 0) {
send_request(ifp, NULL, 0, NULL, 0);
send_update(ifp, 0, NULL, 0, NULL, 0);
}
}
}
if(ifindex_changed)
renumber_filters();
}
开发者ID:jcristau,项目名称:babeld,代码行数:42,代码来源:interface.c
示例11: asio_event_unsubscribe
void asio_event_unsubscribe(asio_event_t* ev)
{
if((ev == NULL) ||
(ev->flags == ASIO_DISPOSABLE) ||
(ev->flags == ASIO_DESTROYED))
return;
asio_backend_t* b = asio_get_backend();
if(ev->noisy)
{
asio_noisy_remove();
ev->noisy = false;
}
epoll_ctl(b->epfd, EPOLL_CTL_DEL, ev->fd, NULL);
if(ev->flags & ASIO_TIMER)
{
if(ev->fd != -1)
{
close(ev->fd);
ev->fd = -1;
}
}
if(ev->flags & ASIO_SIGNAL)
{
int sig = (int)ev->nsec;
asio_event_t* prev = ev;
if((sig < MAX_SIGNAL) && _atomic_cas(&b->sighandlers[sig], &prev, NULL))
{
signal(sig, SIG_DFL);
close(ev->fd);
ev->fd = -1;
}
}
ev->flags = ASIO_DISPOSABLE;
send_request(ev, ASIO_DISPOSABLE);
}
开发者ID:DevL,项目名称:ponyc,代码行数:42,代码来源:epoll.c
示例12: transport_call
/**
* This method is called from the client to start an RPC call.
* @param transport Transport implementation
* @param client Client
* @param method_desc Method descriptor
* @return Returns LWPB_ERR_OK if successful.
*/
static lwpb_err_t transport_call(lwpb_transport_t transport,
struct lwpb_client *client,
const struct lwpb_method_desc *method_desc)
{
struct lwpb_transport_socket_client *socket_client =
(struct lwpb_transport_socket_client *) transport;
lwpb_err_t ret = LWPB_ERR_OK;
void *req_buf = NULL;
size_t req_len;
// Only continue if connected to server
if (socket_client->socket == -1) {
client->done_handler(client, method_desc,
LWPB_RPC_NOT_CONNECTED, client->arg);
goto out;
}
// Allocate a buffer for the request message
ret = lwpb_transport_alloc_buf(transport, &req_buf, &req_len);
if (ret != LWPB_ERR_OK)
goto out;
// Encode the request message
ret = client->request_handler(client, method_desc, method_desc->req_desc,
req_buf, &req_len, client->arg);
if (ret != LWPB_ERR_OK)
goto out;
socket_client->last_method = method_desc;
// Send the request to the server
// TODO check result
send_request(socket_client->socket, method_desc, req_buf, req_len);
out:
// Free allocated requiest message buffer
if (req_buf)
lwpb_transport_free_buf(transport, req_buf);
return ret;
}
开发者ID:jmunnings,项目名称:lwpb,代码行数:49,代码来源:socket_client.c
示例13: authenticate_with_cookie
static int
authenticate_with_cookie(IPC_Channel *chan, cl_uuid_t *cookie)
{
struct ha_msg * request;
struct ha_msg * reply;
assert(chan != NULL);
assert(cookie != NULL);
if (!(request = create_basic_reqmsg_fields(ST_SIGNON))) {
return ST_FAIL;
}
if (ha_msg_adduuid(request, F_STONITHD_COOKIE, cookie) != HA_OK) {
stdlib_log(LOG_ERR, "cannot add field to ha_msg.");
ZAPMSG(request);
return ST_FAIL;
}
/* Send request/read response */
if (send_request(chan, request, DEFAULT_TIMEOUT) != ST_OK) {
ZAPMSG(request);
return ST_FAIL;
}
ZAPMSG(request);
if (!(reply = recv_response(chan, DEFAULT_TIMEOUT))) {
return ST_FAIL;
}
/* Are we signed on this time? */
if ( TRUE == is_expected_msg(reply, F_STONITHD_TYPE, ST_APIRPL,
F_STONITHD_APIRPL, ST_RSIGNON, TRUE) ) {
if ( !STRNCMP_CONST(
cl_get_string(reply,F_STONITHD_APIRET), ST_APIOK) ) {
ZAPMSG(reply);
return ST_OK;
}
}
ZAPMSG(reply);
return ST_FAIL;
}
开发者ID:ClusterLabs,项目名称:pacemaker-1.0,代码行数:42,代码来源:stonithd_lib.c
示例14: main
int main()
{
fd_set rfds;
struct timeval tv;
int sock;
uint32_t xid;
sock = init_socket();
xid = send_request(sock);
FD_ZERO(&rfds);
FD_SET(sock, &rfds);
tv.tv_sec = 5;
tv.tv_usec = 0;
if (select(sock + 1, &rfds, NULL, NULL, &tv) == 1 && FD_ISSET(sock, &rfds))
get_reply(sock, xid);
close(sock);
exit(1);
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:20,代码来源:kpac_dhcp_helper.c
示例15: socket_server_listen
int
socket_server_listen(struct socket_server *ss, const char * addr, int port, int backlog) {
struct request_package request;
int len = (addr!=NULL) ? strlen(addr) : 0;
if (len + sizeof(request.u.listen) > sizeof(request.u)) {
fprintf(stderr, "socket-server : Invalid listen addr %s.\n",addr);
return 0;
}
int session = allocsession(ss);
request.u.listen.session = session;
request.u.listen.port = port;
request.u.listen.backlog = backlog;
if (len == 0) {
request.u.listen.host[0] = '\0';
} else {
strcpy(request.u.listen.host, addr);
}
send_request(ss, &request, 'L', sizeof(request.u.listen) + len);
return session;
}
开发者ID:bikong0411,项目名称:socket-server,代码行数:20,代码来源:socket_server.c
示例16: memset
void *run_chat(void *arg) {
char entree[512];
memset(entree, 0, sizeof(entree));
/*--------------Blocquer les signaux------------------*/
sigset_t mask;
sigfillset(&mask);
pthread_sigmask(SIG_SETMASK, &mask, NULL);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
while (TRUE) {
printf("entrez votre msg : ");
fflush(stdout);
read_response(STDIN_FILENO, entree);
// printf("envois : %s", entree);
send_request(sc, 3, CHAT, myName, entree);
memset(entree, 0, strlen(entree) + 2);
}
return NULL;
}
开发者ID:naaf,项目名称:Master,代码行数:20,代码来源:main.c
示例17: write_buf_cb
static void
write_buf_cb (GObject *object, GAsyncResult *res, gpointer user_data)
{
GOutputStream *output = G_OUTPUT_STREAM (object);
GVfsAfpConnection *afp_conn = G_VFS_AFP_CONNECTION (user_data);
GVfsAfpConnectionPrivate *priv = afp_conn->priv;
RequestData *req_data;
req_data = g_queue_peek_head (priv->request_queue);
HANDLE_RES ();
g_hash_table_insert (priv->request_hash,
GUINT_TO_POINTER ((guint)GUINT16_FROM_BE (priv->write_dsi_header.requestID)),
req_data);
g_queue_pop_head (priv->request_queue);
send_request (afp_conn);
}
开发者ID:Amerekanets,项目名称:gvfs,代码行数:20,代码来源:gvfsafpconnection.c
示例18: get_curl_handle
HTTPCode HttpConnection::send_delete(const std::string& path,
std::map<std::string, std::string>& headers,
std::string& response,
SAS::TrailId trail,
const std::string& body,
const std::string& username)
{
CURL *curl = get_curl_handle();
struct curl_slist *slist = NULL;
slist = curl_slist_append(slist, "Expect:");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
HTTPCode status = send_request(path, body, response, username, trail, "DELETE", curl);
curl_slist_free_all(slist);
return status;
}
开发者ID:telecore-ivan,项目名称:cpp-common,代码行数:20,代码来源:httpconnection.cpp
示例19: test_msg
static void test_msg (flux_t h)
{
flux_msg_handler_t *w;
int i;
ok ((w = flux_msg_handler_create (h, FLUX_MATCH_ANY, msgreader, NULL))
!= NULL,
"msg: created handler for any message");
flux_msg_handler_start (w);
for (i = 0; i < msgwatcher_count; i++) {
if (send_request (h, "foo") < 0)
break;
}
ok (i == msgwatcher_count,
"msg: sent %d requests", i);
ok (flux_reactor_run (flux_get_reactor (h), 0) == 0,
"msg: reactor ran to completion after %d requests", msgwatcher_count);
flux_msg_handler_stop (w);
flux_msg_handler_destroy (w);
}
开发者ID:surajpkn,项目名称:flux-core,代码行数:20,代码来源:reactor.c
示例20: disk_stat
struct p9stat *object_stat(Worker *worker, u64 oid, char *filename) {
int i;
Transaction *trans;
struct Rsstat *res;
struct p9stat *info;
/* handle it from the cache if it exists */
if (object_cache_isvalid(oid)) {
info = disk_stat(worker, oid);
info->name = filename;
return info;
}
i = randInt(storage_server_count);
trans = trans_new(storage_servers[i], NULL, message_new());
trans->out->tag = ALLOCTAG;
trans->out->id = TSSTAT;
set_tsstat(trans->out, oid);
/* send the request to one randomly chosen storage server */
send_request(trans);
assert(trans->in != NULL && trans->in->id == RSSTAT);
res = &trans->in->msg.rsstat;
/* insert the filename supplied by the caller */
res->stat->name = filename;
/* check if we have a cache entry with matching stats */
if (objectroot != NULL && (info = disk_stat(worker, oid)) != NULL) {
info->name = filename;
info->atime = res->stat->atime;
/* if it's up-to-date, note it as a valid entry */
if (!p9stat_cmp(info, res->stat))
object_cache_validate(oid);
}
return res->stat;
}
开发者ID:russross,项目名称:envoy,代码行数:41,代码来源:object.c
注:本文中的send_request函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论