From time to time a table lamp needs the socket replaced. Often, it's because the switch the socket contains is no longer functioning properly. When you replace an old socket, you can feel free to change to some other type of switch. As long as the lamp is wired correctly, you can use any kind of switch you prefer.
Unplug the lamp.
Pry out the socket shell. The socket sits in a base. Insert a screwdriver between the edge of the socket shell and the base, and pry it loose.
Loosen the setscrew so you can unscrew the socket base. The setscrew can be stubborn, particularly if it never has been loosened. The setscrew screws onto a threaded tube that runs through the lamp, top to bottom. Look for a nut at the base of the lamp that holds it all together. Unscrew it if the socket base is stuck, or otherwise is giving you problems. The lamp will come apart, but it is easily reassembled.
Trim and strip the wires, to create a fresh connection. If some of the old strands are broken, trim off a couple of inches, then strip off 1/2 inch of insulation, using wire strippers. Use the correct sized notches when stripping wires. According to FamilyHandyman.com, most lamp cords are 18-gauge, so start with the next largest notch, 16-gauge. If that's still too large, try successively smaller notches, until the strippers grab the wire.
Tie an underwriter's knot in the cord to keep it from slipping free of the socket. See Section 2, "How to Tie an Underwriter's Knot" for step-by-step instructions.
Connect the wires to the socket. Wrap them around the screws, and tighten the screws over the wires. Locate the neutral cord by finding its distinguishing mark. It may be ribbed, may be a different colour, may have printing, or some other indicator. Connect the neutral wire to the silver screw. Trim the wires if they're too long.
Reassemble the lamp, pulling the excess cord through the lamp body. Slip the socket body into the socket cap -- which screws onto the threaded tube -- so it covers the wire. Pull the knot tight against the inside of the socket cap. Make sure the socket body is covered first by the insulating sleeve, then the outer shell.
Cut the cord down the middle with a utility knife so you have about 3 inches of separated wires to work with.
Take the left-hand wire and make a loop to the left around the joined section of the wires. Hold this loop in place with your thumb and index finger.
Loop the right-hand wire under the end of the left-hand wire and over the top of the joined portion of wire.
Pull that right-hand wire through the left-hand loop. Pull both ends tight to form a pretzel shape.
If there is no distinction between the hot wire and the neutral wire, FamilyHandyman.com recommends replacing the cord, as well as the socket.