• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Socket program for linux

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I tried to develop socket program for asterisk connection.I able to run successfully from remote host in windows.But i didn't able run that same socket program in Linux machine..


This is My Socket code

]



Output:
i am getting this error

Response :Error
Message: Missing action in request
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a bad idea to classes like PrintWriter and BufferedReader when working with sockets as end-of-line characters are platform-dependent: don't println to a socket
 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your response.I changed my Socket program wr.print instead of wr.println.But am getting the same error message.Please give any solution to solve this problem.That is very helpful to do contious this process.


Regards,
Suganya.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the code you're now using.

What's with the "searcher" Thread? Is that supposed to do something? Where is the variable defined?
 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Just name for thread.I tried to develop socket program for asterisk connection.I able to run successfully from remote host in windows.But i didn't able run that same socket program in Linux machine..

This the my java code.




Output:
i am getting this error

Response :Error
Message: Missing action in request
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Just name for thread.


Well, it doesn't do anything, so you might as well delete it, lest someone looks at the code and assumes that it's doing something.

You're still using println with a Socket.

What's with the two newline characters after Timeout and Secret - are you sure that those do the right thing?

It's also a bit weird to do anything this involved in a servlet's init method; is this a load-on-startup servlet? If so, you should use a servlet context listener instead, and start whatever it's supposed to be doing in a separate thread (assuming that it's a long-running operation).
 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your response.I changed my code print instead of println.The two newline characters after Timeout and Secret this is correct way for sterisk api command.Am getting the same error....


Regards,
Suganya.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're now using print instead of println, then you're in all likelihood missing some newline characters. That's why I asked you to post your current code.

Are you certain that it's OK to send two "Action" commands in a row?

From http://www.voip-info.org/wiki/view/Asterisk+manager+Example%3A+Login:

Don't forget that you have to end your request with \r\n\r\n (two CrLfs), that's ascii characters 13, 10, 13 and 10 successively.

 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is My changed code.But am also getting the same error....

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd be surprised if it was possible to send command without separating them by a newline character, or some such delimiter.
reply
    Bookmark Topic Watch Topic
  • New Topic