|
OK, I'm sure they have good reasons for that.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
in my case, I'm happy for it. since I gotta learn to read slowly over my code and find errors. and not to get them pointed automaticly right away. had a few dump ins with my brick wall over those cases. from my VB6 days, i see the good side of having something telling what is wrong, since it's great and easy to coede with. But for my school work I preffer TextPad to push myselfh to focus harder on my typings. and not to draw and write a few lines of code. those days will come for sure =)
|
|
|
|
|
You assume errors while developping are always typos.
Unfortunately, that's not the case.
No memory stick has been harmed during establishment of this signature.
|
|
|
|
|
I would like to develop a server with thread and store my data in a .txt file where i can acess with client remotely and read/write the file
|
|
|
|
|
Sounds like a great plan; and which part are you having trouble with?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Steps
1. Gather requirements (nothing to do with code.)
2. Create a design (nothing to do with code.)
3. Implement the design
4. Unit test 3.
If you have trouble with 3, then when you have question about it then you should provide a context from 1 and 2 when you ask the question.
|
|
|
|
|
*sniffsniff*
...smells like homework.
Show us your code and we will help you - but we don't provide homework (unless you pay us...).
regards Torsten
I never finish anyth...
|
|
|
|
|
Greetings to all !
I have just begun learning a development in nio sockets. Just wondering why following code does what it does:
SocketChannel sch = SocketChannel.open();
Selector sel = Selector.open();
try {
sch.configureBlocking(false);
sch.connect(new InetSocketAddress("0", 80));
sch.register(sel,SelectionKey.OP_CONNECT);
sel.select();
Iterator<SelectionKey> it = sel.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey sk = it.next();
it.remove();
if (sk.isConnectable()) {
System.out.println("Connectable.");
System.out.println(sch.finishConnect());
System.out.println(sch.socket().isConnected());
System.out.println(sch.socket().getInetAddress());
}
}
} finally {
sch.close();
sel.close();
}
Its output is:
Connectable.
true
true
/0.0.0.0
Which is imho obviously wrong. When I run this classic io code:
Socket s = new Socket();
s.connect(new InetSocketAddress("0", 80));
This also does not crash. But if I run:
Socket s = new Socket("1",1);
It fails with:
Exception in thread "main" java.net.SocketException: Network is unreachable: connect
...
How should I check for errors during connect ?
Thank you and best regards,
Paul
|
|
|
|
|
ptomask wrote: Which is imho obviously wrong.
You are creating a socket to host name "0", IP address 0.0.0.0 which, if memory serves, is accepted as a valid address (possibly same as localhost). The reason it does not crash is that you are trapping all exceptions and ignoring them; add a catch {} block to your code to trap and diagnose exceptions. Also take a look here[^] to verify the validity of your library calls.
|
|
|
|
|
I understand your points, but if I try anything from following:
sch.connect(new InetSocketAddress("10.78.69.4", 80));
sch.connect(new InetSocketAddress("114", 80));
sch.connect(new InetSocketAddress("123456", 80));
the connect operation succeeds although there is no server...
I thing I am not ignoring exceptions. Yes, there is try-finally, but if there would be an exception, there will be no messages written.
Remember that both SocketChannel and underlying Socket return true when I call isConnected() on them.
Why it returns true, when it is not actually connected ?
Have a nice day and thank you,
Paul
|
|
|
|
|
ptomask wrote: but if there would be an exception, there will be no messages written.
Since you are ignoring all exceptions you cannot be sure of this.
As to why you are getting the results you see, I cannot answer that, I guess you need to look deeper into what is happening at every stage of your code. If I have time later (no promises) I may try a test of this myself.
|
|
|
|
|
I think my problem is now solved.
Actually it was caused by Avast antivirus. The antivirus redirects connections outgoing to (at least) port 80 and completes TCP handshake regardless supplied IP address is reachable or not. In my client application this looks like the remote peer would have actually accepted the connection.
Thank you for your responses, best wishes,
Paul
|
|
|
|
|
ptomask wrote: The antivirus redirects connections outgoing to (at least) port 80
Actually that sounds like something a firewall would do, not an antivirus. I guess your Avast package contains both then.
|
|
|
|
|
ptomask wrote: The antivirus redirects connections outgoing to (at least) port 80
In your previous posts you were specifying port 80 each time you created a socket.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yes, I know. It previously didn't occured to me, that this behaviour could be port dependent in this way.
Anyway after disabling Avast network and web defense, everything seems to be working as expected.
Nice day for you,
Paul
|
|
|
|
|
I ask about Android OS , I heard a lot about it , but i'm begineer
could any body give advice about ??? is it good or there's is something is better ?????
|
|
|
|
|
Here you are[^]
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
gif2020 wrote: is it good or there's is something is better
That isn't valid without a context.
Excluding just tinkering the usage of that is limited to the mobile market and thus in terms of "better" one needs other considerations to determine an answer. For example at the personal level one should consider mobile features/cost. From the market approach one should look at market share and type of market.
|
|
|
|
|
Hi,
I would like to ask how would i be able to catch stacktrace below. The error occured when wrong port/address of the server is provided
and cannot be catch because its not part af any java exceptions.
During wrong input, i would want to display an alert message to the user, instead of the whole stack trace.
generated after this call: org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
Oct 20, 2011 3:27:55 PM com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 10.29.8.102; port: 2800"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(Unknown Source)
at org.omg.CORBA.portable.ObjectImpl._is_a(Unknown Source)
at org.omg.CosNaming.NamingContextExtHelper.narrow(Unknown Source)
at com.sun.corba.se.impl.resolver.INSURLOperationImpl.resolveCorbaname(Unknown Source)
at com.sun.corba.se.impl.resolver.INSURLOperationImpl.resolveINSURL(Unknown Source)
at com.sun.corba.se.impl.resolver.INSURLOperationImpl.operate(Unknown Source)
at com.sun.corba.se.impl.resolver.ORBInitRefResolverImpl.resolve(Unknown Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source)
at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source)
at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(Unknown Source)
at com.oberthur.client.Client.init(Client.java:46)
at com.oberthur.client.Client.main(Client.java:82)
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at java.nio.channels.SocketChannel.open(Unknown Source)
at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(Unknown Source)
Thanks and regards to all.
|
|
|
|
|
Working with string and i for something like this
String test = "this is one test string to show you";
now how do i fish out the last word of that string ?
|
|
|
|
|
You could try lastIndexOf() string[^] to find the last space, and then use substring() to extract the last part. There are other possibilities depending on your exact requirements. Reading the documentation will always help.
|
|
|
|
|
System.out.println(test.substring(test.lastIndexOf(" ")==-1?0:test.lastIndexOf(" ")+1));
This one gives you the last word if there is a space, else the word itself if there is no space.
Use trim beforehand in case if you expect spaces at the end!
-Shenbaga Murugan Paramasivapandian
I hate computers and I just mess them up with my code!
|
|
|
|
|
String test = "this is one test string to show you";
String[] words = test.split(" ");
Then just get the last one in the array.
modified 18-Oct-11 9:35am.
|
|
|
|
|
Okay,u should get last index of space and last index of " first, then use substring(int beginIndex, int endIndex).
|
|
|
|
|
Hello!
First question:
I need to draw something like this in Piccolo, and I don't have a clue to get started with that:
Image
Second question:
I have a moving node on
m_canvas.getCamera().addChild(node);
I move it (scale it) by using the following code:
m_canvas.getCamera().animateToPositionScaleRotation(-1,-1, m_canvas.getCamera().getScale()+0.2,0, 1000);
It scales fine but it always moves position like x +10 & y+10 and I can't figure out a way to get it scale in the same place.
And when the scale reaches a certain point it has to be replaces with another node so I just do
m_canvas.getCamera().removeAllChildren(); is that the correct way?
Final questions
- Is there a way for restricting the area where objects may go? So that the an node can't get dragged off screen?
- What is the right way to draw a line in the middle of the canvas so I can split the Window in 2 seperate areas? (This line can't be scalled)
Thanks a lot to anyone who can help!
Greetz!
|
|
|
|