Contents
Overview
Perforce uses a client/server architecture. Files are created and edited by users on their own client hosts; these files are transferred to and from a shared file repository located on a Perforce server. Every running Perforce system uses a single server and can have many clients.Two programs do the bulk of Perforce's work:
Each Perforce client program needs to know the address and port of the Perforce server with which it communicates. This address is stored in the P4PORT environment variable.
- The p4d program runs on the Perforce server. It manages the shared file repository, and keeps track of users, clients, protections, and other Perforce metadata.
- The p4 program runs on each Perforce client. It sends the users' requests to the p4d server program for processing, and communicates with p4d via TCP/IP.
Before you begin
This chapter assumes that your system administrator has already set up a Perforce server (p4d) for you, and that it is already up and running.If this is not the case (for instance, if you're installing Perforce from scratch), you'll also have to install the Perforce server before continuing. See the appendix, "Installing Perforce" on page 127, for information on how to install the server.
The information in the appendix is intended to help you install a server for evaluation purposes. If you're installing a production server, or are planning on extensive testing of your evaluation server, we strongly encourage you to read the full installation instructions in the Perforce System Administrator's Guide.
Setting up your environment to use Perforce
A Perforce client program needs to know two things in order to talk to a Perforce server:
These are set via a single environment variable, P4PORT.
- the name of the host on which p4d is running, and
- the port on which p4d is listening
If your site is already using Perforce, it's possible that your system administrator has already set P4PORT for you; if not, you'll need to set it yourself.
Either way, after setting P4PORT to point to your server, you should verify your client's connection to the Perforce server with the p4 info command.
Telling Perforce clients where the server is
To use Perforce, you'll need to know the name of the host where p4d is located, and the number of the TCP/IP port on which it's listening.
Once you've obtained the host and port information, set your P4PORT environment variable to host:portNum, where host is the name of the host on which p4d is running, and portNum is the port to which it is listening. For example:
- If you've just installed the Perforce server yourself, you already know this, having configured the server on a specific host to listen to a specific port.
- If you're connecting to an existing Perforce installation, you'll have to ask your system administrator for the host and port of the Perforce server.
If the server is running on... and is listening to port... set P4PORT to: 192.169.1.150 1666 192.169.1.150:1666 acme.com 1818 acme.com:1818
Verifying the connection to the Perforce server
To verify the connection, type p4 info at the command line. If the P4PORT environment variable is correctly set, you'll see something like this:
User name: edk Client name: wrkstn12 Client host: wrkstn12 Client unknown. Current directory: /usr/edk Client address: 192.168.0.123:1818 Server address: p4server:1818 Server root: /usr/depot/p4d Server date: 2000/07/28 12:11:47 PDT Server version: P4D/FREEBSD/2000.1/16375 (2000/07/25) Server license: P4 Admin <p4adm> 20 users on unix (expires 2001/01/01)The Server address: field shows which Perforce server to which the client has connected; it displays the host and port number on which p4d is listening.
In the above example, everything is fine. If, however, you receive a variant of this message:
Perforce client error: Connect to server failed; check $P4PORT. TCP connect to perforce:1666 failed. perforce: host unknown.then P4PORT has not been correctly set. If the value you see in the third line of the error message is perforce:1666 (as above), then P4PORT has not been set at all; if the value is anything else, P4PORT has been incorrectly set. In either case, you'll need to set the value of P4PORT.
On Windows platforms, registry variables are preferred over environment variables, and you can set these with command p4 set.
![]()