Perforce 2000.2 Command Line User's Guide (2000.2.ug.1)
<< Previous Chapter
Perforce Concepts
Table of Contents
Index
Perforce on the Web
Next Chapter >>
Perforce Basics:
Quick Start


Chapter 2
Connecting to the
Perforce Server

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.

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 (e.g., 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 85, 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 our 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: the name of the host on which p4d is running, and the port on which p4d is listening. These are set via a single environment variable, P4PORT.

Note

See "Setting Environment Variables" on page 9 for information about how to set environment variables for most operating systems and shells.

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 the server is running on...
and is listening to port...
set P4PORT to:

dogs

3435

dogs:3435

x.com

1818

x.com:1818

The definition of P4PORT can be shortened if the Perforce client is running on the same host as the server. In this case, only the port number need be provided to p4. If p4d is running on a host named or aliased perforce, listening on port 1666, the definition of P4PORT for the p4 client can be dispensed with altogether. For example:

If the server is running on...
and is listening to port...
set P4PORT to:

<same host as the p4 client>

1543

1543

perforce

1666

<no value needed>

When P4PORT has been set, you should re-verify the connection with p4 info, as described below. Once this has been done, Perforce is ready to use.

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: Susie Superuser <susie> 200 users on freebsd (expires 2001/01/01)

The Server address: field shows which Perforce server the client has connected to; 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.

95/98/NT

On Windows 95 and NT, registry variables are preferred over environment variables, and you can set these with command p4 set.

Setting Environment Variables


Each operating system and shell has its own syntax for setting environment variables. The following table shows how the P4CLIENT environment variable is set in each OS and shell:

OS or Shell
Environment Variable Example

UNIX: ksh, sh, bash

export P4CLIENT=value

UNIX: csh

setenv P4CLIENT value

VMS

def/j P4CLIENT "value"

Mac MPW

set -e P4CLIENT value

Windows 95/98/NT/2000

p4 set P4CLIENT=value

(See the p4 set section of the Perforce Command Reference or run the command p4 help set to obtain more information about setting Perforce's registry variables in Windows).

NT administrators running Perforce as a service can set variables for use by a specific service with p4 set -S svcname var=value.


Perforce 2000.2 Command Line User's Guide (2000.2.ug.1)
<< Previous Chapter
Perforce Concepts
Table of Contents
Index
Perforce on the Web
Next Chapter >>
Perforce Basics:
Quick Start

Please send comments and questions about this manual to [email protected].
Copyright 1997, 1998, 1999, 2000 Perforce Software. All rights reserved.
Last updated: 12/21/00