Solved

http library for solaris 2.5

Posted on 2001-07-03
3
273 Views
Last Modified: 2013-12-27
I am looking for a class library which would eliminate the need to write HTTP at the socket level.

It should be clean enough so that I could do something simple like this example where I establish a connection to a HTTP server, do a HTTP-POST and disconnect.

ClassHTTPStream httpStream;
ClassHTTP httpObj;

try
{
  httpStream = "val=hello world";
  httpObj.connect("4.3.2.1", Port);
  httpObj.Post(httpStream);
  httpObj.disconnect();
}
catch(ClassException E)
{
  // handle http error here
}
0
Comment
Question by:PinTail
3 Comments
 
LVL 1

Expert Comment

by:shanechambers
Comment Utility
Does it have to be in C++?  If not, Perl has lots of libaries for doing things like this.
0
 
LVL 3

Author Comment

by:PinTail
Comment Utility
C++ is a requirement.

This is a server side application communicating with another server side app via an HTTP server.

It sounds kind of dumb to me, but that's what I have been told to do.

I wrote a HTTP Server about 5 years ago, but since then have had NOTHING to do with HTTP, and really don't want to be bothered to write my own library to do this kind of grunt work, I really just want to ship this data via HTTP in the simplest possible way.
0
 
LVL 3

Accepted Solution

by:
graf27 earned 300 total points
Comment Utility
And you can't use Java for the Post-Request ?


import java.net.*;
import java.io.*;

public class MyClass  {

public static void main(String args[]) throws Exception
{


  URL target = new URL("http://servername.com/cgi-bin/serverprogram");
  HttpURLConnection conn =    (HttpURLConnection)target.openConnection();

     conn.setRequestMethod("POST");
     conn.setRequestProperty("Content-type","text/html");
     conn.setDoOutput(true);
     conn.setDoInput(true);
     conn.connect();

     PrintWriter xout = new PrintWriter(conn.getOutputStream());
       xout.println("what you want to post");

     InputStream xin = conn.getInputStream();
    -- Do anything with the response
}

}


On Solaris, you don't need C++ compiler. Just use:

javac  MyClass.java
java MyClass

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now