LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-31-2005, 07:24 AM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
A simple server program in c++


I currently have the following server wrote in vb6:



Option Explicit
Dim sServerMsg As String

Private Sub Form_Load()

'Address must be input as a string
Dim Address As String

'Set the address equal to the web address of the pickle line camera
Address = "http://pl7cam2/operator/image_test.shtml?camNo=1&squarepixel=0&resolution=4CIF&compression=35&color=yes&rotation=0&overlayim age=0&overlaypos=0x0&date=1&clock=1&text=1&textstring=%237%20Pickle%20Exit%20Camera&textcolor=white& textbackgroundcolor=black&textpos=top&duration=NaN&fps=0kkkkkkkkkkkkkkk"

'tells the browser window to display whatever is on the web page of the address
WebBrowser1.Navigate Address

'The port number is arbitrary.
' it's best to use a fairly high number
' because the low numbers are used for
' standard services: 21 for FTP, 23 for telnet,
' 80 for HTTP etc...
Winsock1(0).LocalPort = 10119

'start listening for a connection

Winsock1(0).Listen

'Define the message and show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub



Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)

'the winsock control has to be in a closed state
' before it can do anything else. (like accept a connection)
Winsock1(Index).Close

'Let the winsock close
DoEvents

'accept the connection request
Winsock1(Index).Accept requestID

'Define the message and display it in the list box
sServerMsg = "Serving client!"
List1.AddItem (sServerMsg)
End Sub


Private Sub Winsock1_Close(Index As Integer)

'When the other end has closed the connection,
' close server end too
Winsock1(Index).Close

'to continue listening for another connection
Winsock1(Index).Listen

'show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)

Dim strTemp As String
'Dim strTemp2 As String
Dim a As Integer
'This event fires when the process on the other end of the connection(i.e the client)
'sends data

'retreive data from socket
Winsock1(Index).GetData strTemp
'Winsock1(Index).GetData strTemp2

'The following code separates each part of the string based on the comma
'that is present in the incoming string and parses it out into its
'respective textbox

a = InStr(strTemp, ",")
txtcoilid.Text = Left(strTemp, a - 1)

'after the first parse you must refine the string as everthing after the comma and
'repeat the process throughout the entire string
strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtwidth.Text = Left(strTemp, a - 1)

strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtlinespeed.Text = Left(strTemp, a - 1)

strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtexitcoillength.Text = Left(strTemp, a - 1)


End Sub



I need to code this server on a linux machine using c++ or any other valid linux language. I have no experience in c or c++ coding at all. I was wondering if I could get some insight on some possible translation for this code or some similar source code that may help me.
 
Old 06-02-2005, 02:34 AM   #2
meonkeys
Member
 
Registered: Apr 2004
Location: Minneapolis
Distribution: Ubuntu
Posts: 45

Rep: Reputation: 15
Here is a post about Linux socket programming in C++ that may be of help. I would also recommend Bruce Eckel's Thinking in C++.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple program help! rohitkara Linux - General 1 05-24-2005 08:57 PM
newbie needs help with simple program mastervampire Linux - Newbie 1 03-07-2005 05:26 AM
simple c program liguorir Linux - Software 4 05-29-2004 06:22 AM
simple program bprasanth_20 Programming 5 10-29-2003 12:55 AM
Help with the following simple C program ..... purpleburple Programming 5 09-13-2002 10:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration