can i send function key to unix server through telnet - ios

I want to access unix server on my iPod and this is almost done and i am able to send and receive data from server but when i send a function key (F1, F2,...) to server, server sends me same value that i have sent.
For example : F1 as key code is \e[OP .
My code for this-
SignedByte functionKeyEscSeq[5];
int index=0;
functionKeyEscSeq[index++]='\e';
switch (keyCode) {
case 0://Done
[self unhideAllDefaultButtons];
break;
case 1://F1 //PF1 Key
functionKeyEscSeq[index++]='O';
functionKeyEscSeq[index++]='P';
break;
.....
}
[self sendByte:functionKeyEscSeq toIndex:index]; // Method to send this byte array with socket connection
My Question : Is it possible to send function Key to Server.
If it is possible then please send me some reference or format by which it is possible.

As far I know, you must set your telnet terminal type as TERMINAL_TYPE=vt200 in order to send function keys.

Related

Kafka standalone error: WARN Attempting to send response via channel for which there is no open connection, connection id 0 (kafka.network.Processor)

I install kafka on a standalone server and try to stream data to mongodb.
when start kafka service, bin/kafka-server-start.sh config/server.properties
I had a warning:
WARN Attempting to send response via channel for which there is no open connection, connection id 0 (kafka.network.Processor)
Even though, there is no problem for data entered at producer and displayed at consumer.
but I think this cause the data write to mongodb. I have no data write to mongodb after start data streaming.
anyone can help with this issue? Thank you so much.
//processor.sendResponse
protected[network] def sendResponse(response: RequestChannel.Response) {
trace(s"Socket server received response to send, registering for write and sending data: $response")
val channel = selector.channel(response.responseSend.destination)
// `channel` can be null if the selector closed the connection because it was idle for too long
if (channel == null) {
warn(s"Attempting to send response via channel for which there is no open connection, connection id $id")
response.request.updateRequestMetrics()
}
else {
selector.send(response.responseSend)
inflightResponses += (response.request.connectionId -> response)
}
so, channel was closed by the selector because it was idle too long

Problems subscribing to a room (socket) with Socket.IO-Client-Swift and Swift, Sails.js on the Server

On Swift, I use
socket.on("test") {data, ack in
print(data)
}
In order to subscribe to a room (socket) on my Sails.js API.
When I broadcast a message from the server, with
sails.sockets.broadcast('test', { text : 'ok' })
the socket.on handler is never called.
However, if I set "log" TRUE to config when connecting my socket.io client from swift, in Socket-IO logs the message arrives.
What's wrong?
Eventually, I found my mistake:
The whole process I did is right:
(The request to join the room is done by the server, with sails.sockets.join)
Wrong thing was using socket.on with the ROOM NAME parameter.
I will explain it better, for others having same problem:
From Swift you should subscribe by making a websocket request to an endpoint on the server that accepts websocket requests (GET, POST, PUT). For example, you can make a POST request, passing in the room name into the body.
socket.emitWithAck("post", [
"room": "testroom",
"url": "/api/v1.0/roomsubscribing"
]).timingOut(after: 0) {data in
print("Server responded with \(data)")
}
On server side, inside the room-subscribing endpoint, you should have the following code:
roomSubscribing: function(req, res) {
if (!req.isSocket) {
return res.badRequest();
}
sails.sockets.join(req, req.params('room'), function(err) {
if (err) {
return res.serverError(err);
}
});
}
When the server want to broadcast some data to subscribers of the "testroom" room, the following code must be used:
sails.sockets.broadcast('testroom', { message: 'testmessage' }
Now on the swift's side you must use:
socket.on("message") { data, ack in
print(data)
}
in order to get the message handler to work. I thought you should use room name, instead you should use the KEY of the KEY/VALUE entry you used in your server when you broadcasted the data (in this case, "message").
I only have a small amount of experience with sockets, but in case nobody else answers...
I think you are missing step one of the three step socket process:
A client sends a message to the server asking to subscribe to a particular room.
The client sets up a socket.on to handle particular events from that room.
The server broadcasts an event in a particular room. All subscribers/clients with a .on for that particular event will react.
I could be wrong, but it sounds from your description like you missed step one. Your client has to send a message with io.socket, something like here, then your server has to use the socket request to have them join the room, something like in the example here.
(the presence of log data without the socket.on firing would seem to confirm that the event was broadcast in the room, but that client was not subscribed)
Good luck!

Read message by sequence in socket

I have build a socket to transfer message between client and server on IOS.
if(CFReadStreamSetClient(readStream, registeredEvents, readCallBack, &myContext))
{
CFReadStreamScheduleWithRunLoop(readStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
}
if (!CFReadStreamOpen(readStream)) {
CCLog("Error Open Read Stream");
/* error handling */
}
and readCallBack function
void readCallBack(CFReadStreamRef stream, CFStreamEventType eventType, void *clientCallBackInfo)
{
switch(eventType) {
case kCFStreamEventHasBytesAvailable:{
UInt8 bufr[10240];
int bytesRead = CFReadStreamRead(stream, bufr, sizeof(bufr));
if(bytesRead >0 ){
NSLog(#"Read: %d", bytesRead);
}
break;
}
case kCFStreamEventErrorOccurred:
NSLog(#"A Read Stream Error Has Occurred!");
case kCFStreamEventEndEncountered:
NSLog(#"A Read Stream Event End!");
default:
break;
}
}
But when client send multi message to server by multi time.
Server always read it as one message.
Example:
Client send message 1st: Message1
Client send message 2nd: Message2
But when server read message from client:
Result is: Message1Message2
How can i split it as 2 messages. (I don't know the size of each message)
Thanks.
You have to make up a protocol of your own. For example, clients can append \n to each message so that the server can split messages by \n. However if your messages can have \n character in them, you can modify your protocol to first send the length of the message, again split by \n:
Client sends: 8\nMessage1
Client sends: 14\nAnotherMessage
Server receives: 8\nMessage114\nAnotherMessage
So you read up to first \n and get the content length. Then you read that many characters.
Be careful with the difference between byte streams and text streams though. You can google about TCP text streams to learn more about them. Your best bet is to send number of bytes being sent, instead of number of characters.
And be aware that sometimes, you will not receive a message as a whole. For example the following is possible:
Client sends: 8\nMessage1
Client sends: 14\nAnotherMessage
Server receives: 8\nMessage11
Server receives: 4\nAnotherMessage

Arduino POST vs GET request

I have a bunch of temperature data my Arduino monitors that I want to put into a Google Fusion table. Fusion tables require OAuth for record inserts which the Arduino can't handle (I don't think), I want to create a little app Google's App Engine that will receive the data from the Arduino, then this app will authenticate with the Fusion table and insert a record. Each record would have about 65 fields. I don't know how to do the app on Google App Engine yet, but I'll figure that our separately. What I'd like to know is the pros and cons of sending the data to the app using a GET request or a POST request from my Arduino. For this scenario, is one a better choice then the other?
You will need to use an HTTP POST request if you are wanting to send data from the Arduino.
The difference between the two is that GET is for requesting data from the server, while POST is for sending data to the server.
Here is a link for information about HTTP Message Types:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4
Now for the Arduino code, you need to do the following to send the POST request using the GSM Shield.
//First, establish a connection to the cell tower via GSM
String PIN = "123456"; //The PIN of your SIM card
gsmAccess.begin(PIN);
//Next, connect to your service provider's GPRS network (internet access)
String GPRS_APN = "The APN of your provider";
String GPRS_LOGIN = "Your login name";
String GPRS_PASSWORD = "Your password";
gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);
//Now you need to connect a client to your GAE web server on port 80
client.connect("ServerName", 80);
//Now send the properly-formed HTTP POST request
String message = "The message body of the request, the data you want to send";
client.print("POST ");
client.print("/yourPathToDesiredPage");
client.println(" HTTP/1.1");
client.print("Host: ");
client.println("ServerName");
client.println("Content-Type: text/plain");
client.print("Content-Length: ");
client.println(message.length());
client.println();
client.println(message);
client.endWrite();

How SignalR manages connection between Postbacks

1> Just want to understand how SignalR 1.x functions in a particular scenario
Lets say we have a 10 clients connected to Hub and one of the connected clients say client-1 performs a postback so OnDisconnected is called than OnConnected is called right ?
What happens if during this phase if client-2 try's to send message to client-1 exactly between the said scenario ie (msg is sent after client-1 is disconnected and before connected again )will client-1 miss the message or there's internal mechanism which makes sure client-1 does not miss the message sent by client-2
2> Second query I have is that I'm trying to pass a querystring using following code
var chat = $.connection.myHub;
$.connection.myHub.qs = { "token": "hello" };
but not able to retrieve it on the server side from the Context object
using
Context.QueryString.AllKeys
I even tried
var chat = $.connection.myHub;
$.connection.myHub.qs = "token=hello" ;
But it does not work ie when I check the keys, token is not present in AllKeys
Will appreciate if someone just help me out.
1: If a postback occurs a client will disconnect and then connect. However, when the client performs a connect again it will have a different Connection Id than it had prior to the postback. Therefore, any message sent to the old connection id will be missed because when the users browser connects again it will be known as a different client.
2: You're trying to set the query string on the hub proxy, not the connection. What you should be doing is:
$.connection.hub.qs = { foo: "bar" };

Resources