本文整理汇总了C++中ConnectionState::os方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionState::os方法的具体用法?C++ ConnectionState::os怎么用?C++ ConnectionState::os使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionState
的用法示例。
在下文中一共展示了ConnectionState::os方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send_net_data
void send_net_data(JOCTET *data, int len, void *client) {
dbg_printf("Send %d bytes\n", len);
ConnectionState *p = (ConnectionState *)client;
char hdr[1000];
sprintf(hdr,"\n");
const char *brk = "\n";
if (hdr[1]=='\0') {
brk = "\r\n";
}
dbg_printf("Using terminator %s\n",(hdr[1]=='\0')?"\\r\\n":"\\n");
sprintf(hdr,"Content-Type: image/jpeg%s\
Content-Length: %d%s%s", brk, len, brk, brk);
Bytes hbuf(hdr,strlen(hdr));
p->os().write(hbuf);
Bytes buf((char *)data,len);
/*
// add corruption now and then, for testing.
static int ct = 0;
ct++;
if (ct==50) {
printf("Adding corruption\n");
buf.get()[0] = 'z';
ct = 0;
}
*/
p->os().write(buf);
sprintf(hdr,"%s--boundarydonotcross%s",brk,brk);
Bytes hbuf2(hdr,strlen(hdr));
p->os().write(hbuf2);
}
示例2: write
bool AbstractCarrier::write(ConnectionState& proto, SizedWriter& writer) {
bool ok = sendIndex(proto,writer);
if (!ok) {
return false;
}
writer.write(proto.os());
proto.os().flush();
return proto.os().isOk();
}
示例3:
bool yarp::os::impl::TextCarrier::respondToHeader(ConnectionState& proto)
{
std::string from = "Welcome ";
from += proto.getRoute().getFromName();
from += "\r\n";
yarp::os::Bytes b2((char*)from.c_str(), from.length());
proto.os().write(b2);
proto.os().flush();
return proto.os().isOk();
}
示例4: getSpecifierName
bool yarp::os::impl::TextCarrier::sendHeader(ConnectionState& proto)
{
std::string target = getSpecifierName();
yarp::os::Bytes b((char*)target.c_str(), 8);
proto.os().write(b);
std::string from = proto.getSenderSpecifier();
yarp::os::Bytes b2((char*)from.c_str(), from.length());
proto.os().write(b2);
proto.os().write('\r');
proto.os().write('\n');
proto.os().flush();
return proto.os().isOk();
}
示例5: sendHeader
bool MpiCarrier::sendHeader(ConnectionState& proto) {
// Send the "magic number" for this carrier
ManagedBytes header(8);
getHeader(header.bytes());
proto.os().write(header.bytes());
if (!proto.os().isOk()) return false;
// Now we can do whatever we want, as long as somehow
// we also send the name of the originating port
name = proto.getRoute().getFromName();
other = proto.getRoute().getToName();
Bytes b2((char*)name.c_str(),name.length());
proto.os().write(b2);
proto.os().write('\r');
proto.os().write('\n');
// Sender
route = name + "->" + other;
createStream(true);
if (!MpiControl) return false;
if (! MpiControl->isRunning())
return false;
comm->openPort();
char* port = comm->port_name;
char* uid = comm->unique_id;
#ifdef MPI_DEBUG
printf("[MpiCarrier @ %s] setting up MpiPort '%s'\n", route.c_str(), port);
#endif
Bytes b4(uid,strlen(uid));
proto.os().write(b4);
proto.os().write('\r');
proto.os().write('\n');
Bytes b3(port,strlen(port));
proto.os().write(b3);
proto.os().write('\r');
proto.os().write('\n');
proto.os().flush();
#ifdef MPI_DEBUG
printf("[MpiCarrier @ %s] Header sent\n", route.c_str());
#endif
return proto.os().isOk();
}
示例6: writeYarpInt
void AbstractCarrier::writeYarpInt(int n, ConnectionState& proto)
{
char buf[8];
Bytes header(&(buf[0]), sizeof(buf));
createYarpNumber(n, header);
proto.os().write(header);
}
示例7: reply
bool TcpRosCarrier::reply(ConnectionState& proto, SizedWriter& writer) {
char twiddle[1];
twiddle[0] = 1;
Bytes twiddle_buf(twiddle,1);
proto.os().write(twiddle_buf);
return write(proto,writer);
}
示例8: sendConnectionStateSpecifier
bool AbstractCarrier::sendConnectionStateSpecifier(ConnectionState& proto) {
char buf[8];
Bytes header((char*)&buf[0],sizeof(buf));
OutputStream& os = proto.os();
proto.getConnection().getHeader(header);
os.write(header);
os.flush();
return os.isOk();
}
示例9: sendHeader
bool MjpegCarrier::sendHeader(ConnectionState& proto) {
Name n(proto.getRoute().getCarrierName() + "://test");
ConstString pathValue = n.getCarrierModifier("path");
ConstString target = "GET /?action=stream\n\n";
if (pathValue!="") {
target = "GET /";
target += pathValue;
}
target += " HTTP/1.1\n\n";
Bytes b((char*)target.c_str(),target.length());
proto.os().write(b);
return true;
}
示例10: sendSenderSpecifier
bool AbstractCarrier::sendSenderSpecifier(ConnectionState& proto) {
NetInt32 numberSrc;
Bytes number((char*)&numberSrc,sizeof(NetInt32));
const String senderName = proto.getSenderSpecifier();
//const String& senderName = getRoute().getFromName();
NetType::netInt((int)senderName.length()+1,number);
OutputStream& os = proto.os();
os.write(number);
Bytes b((char*)senderName.c_str(),senderName.length()+1);
os.write(b);
os.flush();
return os.isOk();
}
示例11: expectReplyToHeader
bool MpiCarrier::expectReplyToHeader(ConnectionState& proto) {
// SWITCH TO NEW STREAM TYPE
if (!comm->accept()) {
delete stream;
return false;
}
proto.takeStreams(stream);
#ifdef MPI_DEBUG
printf("[MpiCarrier @ %s] MpiStream successfully setup \n", route.c_str() );
#endif
return proto.os().isOk();
}
示例12: sendHeader
bool XmlRpcCarrier::sendHeader(ConnectionState& proto) {
shouldInterpretRosMessages(proto);
ConstString target = "POST /RPC2";
Name n(proto.getRoute().getCarrierName() + "://test");
ConstString pathValue = n.getCarrierModifier("path");
if (pathValue!="") {
target = "POST /";
target += pathValue;
// on the wider web, we should provide real host names
host = NetworkBase::queryName(proto.getRoute().getToName());
}
target += " HTTP/1.1\n";
http = target;
Bytes b((char*)target.c_str(),target.length());
proto.os().write(b);
return true;
}
示例13: b
bool yarp::os::impl::HttpCarrier::sendHeader(ConnectionState& proto) {
ConstString target = "GET / HTTP/1.0\r\n";
ConstString path = proto.getRoute().getToName();
if (path.size()>=2) {
target = "GET " + path + " HTTP/1.0\r\n";
}
Contact host = proto.getRoute().getToContact();
if (host.getHost()!="") {
target += "Host: ";
target += host.getHost();
target += "\r\n";
}
target += "\r\n";
Bytes b((char*)target.c_str(),target.length());
proto.os().write(b);
return true;
}
示例14: defaultSendIndex
bool AbstractCarrier::defaultSendIndex(ConnectionState& proto, SizedWriter& writer)
{
writeYarpInt(10, proto);
int len = (int)writer.length();
char lens[] = { (char)len, (char)1,
(char)-1, (char)-1, (char)-1, (char)-1,
(char)-1, (char)-1, (char)-1, (char)-1 };
Bytes b(lens, 10);
OutputStream& os = proto.os();
os.write(b);
NetInt32 numberSrc;
Bytes number((char*)&numberSrc, sizeof(NetInt32));
for (int i=0; i<len; i++) {
NetType::netInt((int)writer.length(i), number);
os.write(number);
}
NetType::netInt(0, number);
os.write(number);
return os.isOk();
}
示例15:
bool yarp::os::impl::HttpCarrier::write(ConnectionState& proto, SizedWriter& writer) {
DummyConnector con;
con.setTextMode(true);
for (size_t i=writer.headerLength(); i<writer.length(); i++) {
con.getWriter().appendBlock(writer.data(i),writer.length(i));
}
Bottle b;
b.read(con.getReader());
ConstString body = b.find("web").toString();
if (body.length()!=0) {
ConstString header;
header += NetType::toHexString(body.length()).c_str();
header += "\r\n";
Bytes b2((char*)header.c_str(),header.length());
proto.os().write(b2);
Bytes b3((char*)body.c_str(),body.length());
proto.os().write(b3);
proto.os().write('\r');
proto.os().write('\n');
} else {
ConstString txt = b.toString() + "\r\n";
ConstString header;
header += NetType::toHexString(txt.length()).c_str();
header += "\r\n";
Bytes b2((char*)header.c_str(),header.length());
proto.os().write(b2);
Bytes b3((char*)txt.c_str(),txt.length());
proto.os().write(b3);
proto.os().write('\r');
proto.os().write('\n');
}
proto.os().flush();
return proto.os().isOk();
}