2 Main

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1112 Views - Last Post: 02 November 2010 - 12:35 PM Rate Topic: -----

#1 Apprentice123  Icon User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

2 Main

Posted 30 October 2010 - 12:10 PM

How to run two main in c++ ?
Is This A Good Question/Topic? 0
  • +

Replies To: 2 Main

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: 2 Main

Posted 30 October 2010 - 12:27 PM

Not possible. Want to explain what you actually want?
Was This Post Helpful? 0
  • +
  • -

#3 Munawwar  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 162
  • View blog
  • Posts: 457
  • Joined: 20-January 10

Re: 2 Main

Posted 30 October 2010 - 12:46 PM

Maybe you want to execute code concurrently...that's multi-threading. With windows API you can use CreateThread to do that.
Was This Post Helpful? 0
  • +
  • -

#4 Apprentice123  Icon User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

Re: 2 Main

Posted 30 October 2010 - 04:17 PM

View PostMunawwar, on 30 October 2010 - 11:46 AM, said:

Maybe you want to execute code concurrently...that's multi-threading. With windows API you can use CreateThread to do that.


Yes I am working with socket. WINSOCK2.H I have a main to the server, and other main to the client.
I'm having error:
multiple definition of `main'

Was This Post Helpful? 0
  • +
  • -

#5 Coding in the name of  Icon User is offline

  • D.I.C Head

Reputation: 67
  • View blog
  • Posts: 232
  • Joined: 07-July 10

Re: 2 Main

Posted 30 October 2010 - 04:30 PM

You could supply an argument to the program indicating whether to run it in server or client mode.
Was This Post Helpful? 0
  • +
  • -

#6 Apprentice123  Icon User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

Re: 2 Main

Posted 30 October 2010 - 04:41 PM

View PostCoding in the name of, on 30 October 2010 - 03:30 PM, said:

You could supply an argument to the program indicating whether to run it in server or client mode.


But I need to run both, one for connecting with others, establishing a connection.
Was This Post Helpful? 0
  • +
  • -

#7 Coding in the name of  Icon User is offline

  • D.I.C Head

Reputation: 67
  • View blog
  • Posts: 232
  • Joined: 07-July 10

Re: 2 Main

Posted 30 October 2010 - 05:11 PM

You need two instances of the program running at the same time. A program instance isn't usually a client and a server at the same time.
Was This Post Helpful? 0
  • +
  • -

#8 Apprentice123  Icon User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

Re: 2 Main

Posted 30 October 2010 - 05:46 PM

View PostCoding in the name of, on 30 October 2010 - 04:11 PM, said:

You need two instances of the program running at the same time. A program instance isn't usually a client and a server at the same time.


OK. But I just do not know how.
Was This Post Helpful? 0
  • +
  • -

#9 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: 2 Main

Posted 30 October 2010 - 06:34 PM

Are you trying to say you have one program that runs on/as the server and one program that runs on/as the client?

If you aren't writing two different programs why aren't you?
Was This Post Helpful? 0
  • +
  • -

#10 Apprentice123  Icon User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

Re: 2 Main

Posted 31 October 2010 - 05:40 AM

View Postjanotte, on 30 October 2010 - 05:34 PM, said:

Are you trying to say you have one program that runs on/as the server and one program that runs on/as the client?

If you aren't writing two different programs why aren't you?


It's all the same project. I used functions for client and server establish a TCP connection
Was This Post Helpful? 0
  • +
  • -

#11 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: 2 Main

Posted 31 October 2010 - 05:44 AM

If that makes sense to you then you go with that idea.

It makes no sense to me but it's not my challenge.
Was This Post Helpful? 0
  • +
  • -

#12 Apprentice123  Icon User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

Re: 2 Main

Posted 31 October 2010 - 03:57 PM

View Postjanotte, on 31 October 2010 - 04:44 AM, said:

If that makes sense to you then you go with that idea.

It makes no sense to me but it's not my challenge.


Here is an example of what I'm talking about:
http://www.adp-gmbh....sc/sockets.html
Was This Post Helpful? 0
  • +
  • -

#13 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: 2 Main

Posted 31 October 2010 - 04:10 PM

You realize those are separate programs, right? As in, a separate client and server program? Actually, if you were to properly understand the above link, the person created a socket class. Then created four separate demo programs.

Are you just blindly copy pasting code without even understanding it...?

This post has been edited by Oler1s: 31 October 2010 - 04:10 PM

Was This Post Helpful? 2
  • +
  • -

#14 Apprentice123  Icon User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

Re: 2 Main

Posted 31 October 2010 - 04:53 PM

View PostOler1s, on 31 October 2010 - 03:10 PM, said:

You realize those are separate programs, right? As in, a separate client and server program? Actually, if you were to properly understand the above link, the person created a socket class. Then created four separate demo programs.

Are you just blindly copy pasting code without even understanding it...?


I have not used this code. I did mine, but I have two main, and do not know how to connect (main client) with (main server)
Was This Post Helpful? 0
  • +
  • -

#15 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: 2 Main

Posted 31 October 2010 - 05:33 PM

You have two programs. If they are designed to communicate with one another, you just run the programs...?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2