Skip to main content

How do I create a socket to a Java transaction server?

1 reply [Last post]
kellogg
Offline
Joined: 2006-02-17

My question is how do I create a socket? How do I run this sample code,
what tool do I use? It says to make a socket to Java Transaction Server(JTS).
Thank you for your help.

<?xml version="1.0"?>

NGOConnectCabinet
SAMPLEDB
s
s
2001-12-31
Y

S

Socket sock = new Socket (jtsIP, jtsPort)
DataOutputStream oOut = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()))
Int strLen = inputXMLString.length();
oOut.writeInt(strLen);
byte[] SendStream = new byte[strLen];
SendStream = inputXMLString.getBytes("8859_1");
oOut.writeInt(strLen);
oOut.write(SendStream, 0, strLen);
oOut.flush();

DataInputStream oIn = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
int length = 0;
length = oIn.readInt();
byte[] readStream = new byte[length];
oIn.readFully(readStream);
String stroutputXML = new String(readStream, "8859_1");

Thank you for your help.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
zander
Offline
Joined: 2003-06-13

I suggest you go and buy one of those Java in 24 hours books, since making code compile and work is out of the scope for these forums.