提交 ae823bf9 编写于 作者: X xwhqsj

update socket

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