{"action":"created","issue":{"url":"https://api.github.com/repos/m8rge/cwebsocket/issues/21","repository_url":"https://api.github.com/repos/m8rge/cwebsocket","labels_url":"https://api.github.com/repos/m8rge/cwebsocket/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/m8rge/cwebsocket/issues/21/comments","events_url":"https://api.github.com/repos/m8rge/cwebsocket/issues/21/events","html_url":"https://github.com/m8rge/cwebsocket/issues/21","id":132883309,"number":21,"title":"recv == 0","user":{"login":"wumao","id":159140,"avatar_url":"https://avatars.githubusercontent.com/u/159140?v=3","gravatar_id":"","url":"https://api.github.com/users/wumao","html_url":"https://github.com/wumao","followers_url":"https://api.github.com/users/wumao/followers","following_url":"https://api.github.com/users/wumao/following{/other_user}","gists_url":"https://api.github.com/users/wumao/gists{/gist_id}","starred_url":"https://api.github.com/users/wumao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wumao/subscriptions","organizations_url":"https://api.github.com/users/wumao/orgs","repos_url":"https://api.github.com/users/wumao/repos","events_url":"https://api.github.com/users/wumao/events{/privacy}","received_events_url":"https://api.github.com/users/wumao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-11T04:14:32Z","updated_at":"2016-02-11T12:41:54Z","closed_at":null,"body":"ssize_t readed = recv(clientSocket, gBuffer+readedLength, BUF_LEN-readedLength, 0);\r\n\r\nI compile this lib use mipsel-openwrt-linux-gcc.  run on router.\r\n\r\nmaybe void wsGetHandshakeAnswer(const struct handshake *hs, uint8_t *outFrame,  *outLength)\r\nhave a bad responseKey\r\non x86 it is ok."},"comment":{"url":"https://api.github.com/repos/m8rge/cwebsocket/issues/comments/182843537","html_url":"https://github.com/m8rge/cwebsocket/issues/21#issuecomment-182843537","issue_url":"https://api.github.com/repos/m8rge/cwebsocket/issues/21","id":182843537,"user":{"login":"wumao","id":159140,"avatar_url":"https://avatars.githubusercontent.com/u/159140?v=3","gravatar_id":"","url":"https://api.github.com/users/wumao","html_url":"https://github.com/wumao","followers_url":"https://api.github.com/users/wumao/followers","following_url":"https://api.github.com/users/wumao/following{/other_user}","gists_url":"https://api.github.com/users/wumao/gists{/gist_id}","starred_url":"https://api.github.com/users/wumao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wumao/subscriptions","organizations_url":"https://api.github.com/users/wumao/orgs","repos_url":"https://api.github.com/users/wumao/repos","events_url":"https://api.github.com/users/wumao/events{/privacy}","received_events_url":"https://api.github.com/users/wumao/received_events","type":"User","site_admin":false},"created_at":"2016-02-11T12:41:53Z","updated_at":"2016-02-11T12:41:53Z","body":"/**\r\n\t* characters used for Base64 encoding\r\n\t*/\r\n\tstatic const char *BASE64_CHARS = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\r\n\r\n\t/**\r\n\t* encode three bytes using base64 (RFC 3548)\r\n\t*\r\n\t* @param triple three bytes that should be encoded\r\n\t* @param result buffer of four characters where the result is stored\r\n\t*/\r\n\tstatic void _base64_encode_triple(unsigned char triple[3], char result[4])\r\n\t{\r\n\t\tint tripleValue, i;\r\n\r\n\t\ttripleValue = triple[0];\r\n\t\ttripleValue *= 256;\r\n\t\ttripleValue += triple[1];\r\n\t\ttripleValue *= 256;\r\n\t\ttripleValue += triple[2];\r\n\r\n\t\tfor (i = 0; i<4; i++)\r\n\t\t{\r\n\t\t\tresult[3 - i] = BASE64_CHARS[tripleValue % 64];\r\n\t\t\ttripleValue /= 64;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t* encode an array of bytes using Base64 (RFC 3548)\r\n\t*\r\n\t* @param source the source buffer\r\n\t* @param sourcelen the length of the source buffer\r\n\t* @param target the target buffer\r\n\t* @param targetlen the length of the target buffer\r\n\t* @return 1 on success, 0 otherwise\r\n\t*/\r\n\tstatic int base64_encode(char *target, size_t targetlen, unsigned char *source, size_t sourcelen)\r\n\t{\r\n\t\t/* check if the result will fit in the target buffer */\r\n\t\tif ((sourcelen + 2) / 3 * 4 > targetlen - 1)\r\n\t\t\treturn 0;\r\n\r\n\t\t/* encode all full triples */\r\n\t\twhile (sourcelen >= 3)\r\n\t\t{\r\n\t\t\t_base64_encode_triple(source, target);\r\n\t\t\tsourcelen -= 3;\r\n\t\t\tsource += 3;\r\n\t\t\ttarget += 4;\r\n\t\t}\r\n\r\n\t\t/* encode the last one or two characters */\r\n\t\tif (sourcelen > 0)\r\n\t\t{\r\n\t\t\tunsigned char temp[3];\r\n\t\t\tmemset(temp, 0, sizeof(temp));\r\n\t\t\tmemcpy(temp, source, sourcelen);\r\n\t\t\t_base64_encode_triple(temp, target);\r\n\t\t\ttarget[3] = '=';\r\n\t\t\tif (sourcelen == 1)\r\n\t\t\t\ttarget[2] = '=';\r\n\r\n\t\t\ttarget += 4;\r\n\t\t}\r\n\r\n\t\t/* terminate the string */\r\n\t\ttarget[0] = 0;\r\n\r\n\t\treturn 1;\r\n\t}\r\nuse this base64_encode.  from \r\nhttps://github.com/payden/libwebsock/blob/master/src/base64.c"}}