Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » TCP/IP(TCP client or server bundle)
TCP/IP [message #1776248] Tue, 14 November 2017 13:16 Go to next message
gopal korrapati is currently offline gopal korrapatiFriend
Messages: 48
Registered: October 2017
Member
Hello every one
I did a TCP/IP client and server bundles and I installed in kura also but after starting the bundle I got some errors in debugging logs like as bellow
javax.microedition.io.ConnectionNotFoundException
please help me.
Re: TCP/IP [message #1776249 is a reply to message #1776248] Tue, 14 November 2017 13:18 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
are you sure that your manifest file imports correctly all the needed dependencies?

Anyway a proper piece of code/log with the error is needed in order to understand and be able to give proper advice.

Best regards,
Matteo
Re: TCP/IP [message #1776252 is a reply to message #1776248] Tue, 14 November 2017 13:35 Go to previous messageGo to next message
gopal korrapati is currently offline gopal korrapatiFriend
Messages: 48
Registered: October 2017
Member
No Message Body
Re: TCP/IP [message #1776289 is a reply to message #1776252] Wed, 15 November 2017 05:40 Go to previous messageGo to next message
gopal korrapati is currently offline gopal korrapatiFriend
Messages: 48
Registered: October 2017
Member
these is the manifest for the server bundle
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Server
Bundle-SymbolicName: org.eclipse.kura.example.server
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.comm;version="1.2.0",
javax.microedition.io;resolution:=optional,
javax.net,
javax.net.ssl,
org.osgi.framework;version="1.8.0",
org.osgi.service.io;version="[1.0,2.0)",
org.slf4j;version="1.7.21"
Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy

And these are the logs after starting the two bundles

ServerExample - Bundle org.eclipse.kura.example.server has started!

ServerExample -javax.microedition.io.ConnectionNotFoundException

ClientExample - Bundle org.eclipse.kura.example.client has started!

ClientExample - clientjavax.microedition.io.ConnectionNotFoundException

Re: TCP/IP [message #1776290 is a reply to message #1776289] Wed, 15 November 2017 05:49 Go to previous messageGo to next message
gopal korrapati is currently offline gopal korrapatiFriend
Messages: 48
Registered: October 2017
Member
these is the link I followed to build a client and server bundles.
http://dz.prosyst.com/pdoc/mBS_SDK_7.2.0/um/runtime/osgi/docs/framework/bundles/osgi/connector/connector.html
Re: TCP/IP [message #1776298 is a reply to message #1776290] Wed, 15 November 2017 07:31 Go to previous messageGo to next message
gopal korrapati is currently offline gopal korrapatiFriend
Messages: 48
Registered: October 2017
Member
In my import window I see some "QUESTION" mark. I attched the attachment.file:///home/gopal/Pictures/Screenshot%20from%202017-11-15%2012:53:54.png
Re: TCP/IP [message #1776302 is a reply to message #1776298] Wed, 15 November 2017 08:40 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Referring to the code you posted, the error seems not related to an error importing the java.microedition package. So, it's not a Class not found exception but an exception thrown while invoking the
connService.open
.

I would suggest starting working on that. Maybe you can try to debug your code in order to see what is going on.

Best regards,
Matteo
Re: TCP/IP [message #1776307 is a reply to message #1776302] Wed, 15 November 2017 09:03 Go to previous messageGo to next message
gopal korrapati is currently offline gopal korrapatiFriend
Messages: 48
Registered: October 2017
Member
you have any example code regarding these tcp/ip client and server bundle. please share me?
Re: TCP/IP [message #1776308 is a reply to message #1776307] Wed, 15 November 2017 09:04 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
I'm sorry, but I don't
Re: TCP/IP [message #1776388 is a reply to message #1776308] Thu, 16 November 2017 05:25 Go to previous messageGo to next message
gopal korrapati is currently offline gopal korrapatiFriend
Messages: 48
Registered: October 2017
Member
these is my client and server code is there any errors in these please tell me
client:-
import org.osgi.service.io.ConnectorService;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.ConnectionNotFoundException;
import java.io.DataOutputStream;
import org.osgi.framework.*;
import java.io.IOException;

public class IOClient implements BundleActivator {

private ServiceReference connRef;
private ConnectorService connService;
private StreamConnection connection;

public void start(BundleContext bc) {

connRef = bc.getServiceReference(ConnectorService.class.getName());

if (connRef != null) {
connService = (ConnectorService)bc.getService(connRef);
try {
//passing the client socket URI. Note that we create a StreamConnection
connection = (StreamConnection)connService.open("socket://localhost:3333");
DataOutputStream outputStream = connection.openDataOutputStream();
//the simple String data sent to the server
outputStream.writeUTF("Hello there from the client!");
} catch(ConnectionNotFoundException ce) {
ce.printStackTrace();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
}

public void stop(BundleContext bc) {
try {
connection.close();//not forgetting to close the connection
} catch(IOException ioe) {
ioe.printStackTrace();
}
bc.ungetService(connRef);
}
}


server:-
import org.osgi.service.io.ConnectorService;
import javax.microedition.io.StreamConnection;

import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.StreamConnectionNotifier;
import java.io.DataInputStream;
import org.osgi.framework.*;
import java.io.IOException;
public class IOServer extends Thread implements BundleActivator {

private ServiceReference connRef;
private ConnectorService connService;
private StreamConnection connection;
private StreamConnectionNotifier server;

public void start(BundleContext bc) {

connRef = bc.getServiceReference(ConnectorService.class.getName());

if (connRef != null) {
connService = (ConnectorService)bc.getService(connRef);

try {
//Creates a read-only server connection on port 3333
server = (StreamConnectionNotifier)connService.open("socket://:3333",
ConnectorService.READ);
} catch(ConnectionNotFoundException ce) {
ce.printStackTrace();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
start();
}

public void run() {
try {
//accepting the data input from clients
connection = server.acceptAndOpen();
DataInputStream inputStream = connection.openDataInputStream();
while(true) {
String input = inputStream.readUTF();//we expect String data
while(input != null) {
System.out.println(input);
input = inputStream.readUTF();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

public void stop(BundleContext bc) {
try {
connection.close();//finally, we close the connection

} catch(IOException ioe) {
ioe.printStackTrace();
}
bc.ungetService(connRef);
}
Re: TCP/IP [message #1776406 is a reply to message #1776388] Thu, 16 November 2017 08:42 Go to previous message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
as said in one of my previous comments: Did you try to perform some debugging on the code?

Maybe you can also try to use other code snippets. A simple search can take, for example, to this: http://cs.lmu.edu/~ray/notes/javanetexamples/

Best regards,
Matteo
Previous Topic:Kura 3.1.0 wifi configuration
Next Topic:Helloworld
Goto Forum:
  


Current Time: Fri Mar 29 00:28:09 GMT 2024

Powered by FUDForum. Page generated in 0.03391 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top