[vtkusers] java + sockets
Christopher M. Navarro
cnavarro at ncsa.uiuc.edu
Fri Jul 11 12:57:50 EDT 2003
I'm trying to send a string across a socket from a java client to a c++
server and I'm not sure what I'm doing wrong. Here is a snip of code:
in java:
vtkSocketController contr = new vtkSocketController();
contr.Initialize();
vtkSocketCommunicator comm = new vtkSocketCommunicator();
String test = new String("test");
if(comm.ConnectTo(hostname,port) ==0) {
// do the right thing if the connect failed
}
if(comm.Send(test, 4, 1, 33) == 0) {
// do the right thing if the send failed
}
in c++:
char msg[4];
if(comm->Receive(msg, 4, 1, 33) == 0) {
// do the right thing if it failed
}
This works fine but when I try
cout << msg[0];
The program crashes. Any ideas as to what I'm doing wrong?
-chris
More information about the vtkusers
mailing list