提交 ae823bf9 编写于 作者: X xwhqsj

update socket

上级 f8420398
......@@ -52,15 +52,3 @@ int main()
read(sock, buffer, 1024);
printf("%s\n", buffer);
}
int i;
for(i = 0; i < strlen(buffer); i++)
{
if(buffer[i] == '$')
{
strncpy(psql, buffer, i);
strncpy(dbn, buffer + i + 1, strlen(buffer) - i - 1);
}
}
printf("%s\n", psql);
printf("%s\n", dbn);
......@@ -4,7 +4,6 @@
#include <cstdlib>
#include <netinet/in.h>
#include <cstring>
#include <iostream>
#include <vector>
#define PORT 8080
......
......@@ -7,8 +7,9 @@
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <jni.h>
#include "tpool.h"
......@@ -39,23 +40,28 @@ void* handle_stream(void* myJvm, void* arg)
{
int server_fd = (int&)arg;
char buf[1024];
char* psql;
char* dbn;
read(server_fd, buf, 1024);
printf("%s\n", buf);
int i;
for(i = 0; i < strlen(buf); i++)
{
if(buf[i] == '$')
char* psql;
char* dbn;
char delims[] = "$";
char *res = nullptr;
std::vector<char*> resvec;
res = strtok(buf, delims);
while (res != nullptr)
{
strncpy(psql, buf, i);
strncpy(dbn, buf + i + 1, strlen(buf) - i - 1);
}
resvec.push_back(res);
res = strtok(nullptr, delims);
}
jvmThreads(arg, psql, dbn);
psql = resvec[0];
dbn = resvec[1];
jvmThreads(myJvm, psql, dbn);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册